author | ymh <ymh.work@gmail.com> |
Tue, 14 Oct 2014 05:07:37 +0200 | |
changeset 22 | 986ee928a866 |
parent 13 | 435d5c15275a |
permissions | -rw-r--r-- |
0 | 1 |
|
2 |
# |
|
3 |
# See LICENCE for detail |
|
4 |
# Copyright (c) 2014 IRI |
|
5 |
# |
|
6 |
||
2
fc1ab0074e29
export config in config file + add static file
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
7 |
import os.path |
0 | 8 |
import sys |
9 |
||
10 |
import psycopg2.extras |
|
11 |
||
12 |
from twisted.application import service |
|
22
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
13 |
from twisted.internet import reactor |
0 | 14 |
from twisted.python import log |
15 |
from txpostgres import txpostgres |
|
16 |
||
17 |
from annotserver import make_service |
|
13
435d5c15275a
clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
18 |
import config |
22
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
19 |
from database import create_connection_pool, init_db, db_session |
0 | 20 |
|
21 |
||
22 |
psycopg2.extras.register_uuid() |
|
23 |
||
24 |
||
22
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
25 |
init_db() |
13
435d5c15275a
clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
26 |
conn, d = create_connection_pool(config.CONN_STR) |
0 | 27 |
#to do treat error |
22
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
28 |
#d.addCallback(lambda _: conn.runOperation(get_table_create_stmt())) |
0 | 29 |
|
30 |
#TOODO Log |
|
31 |
#log.startLogging(sys.stdout) |
|
32 |
||
33 |
||
34 |
application = service.Application("annot-server") |
|
35 |
||
13
435d5c15275a
clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
36 |
annotserver = make_service(conn) |
0 | 37 |
annotserver.setServiceParent(service.IServiceCollection(application)) |
22
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
38 |
|
986ee928a866
add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
39 |
reactor.addSystemEventTrigger('before', 'shutdown', lambda: db_session.remove()) |