annot-server/server.tac
changeset 22 986ee928a866
parent 13 435d5c15275a
--- a/annot-server/server.tac	Tue Oct 14 18:00:13 2014 +0200
+++ b/annot-server/server.tac	Tue Oct 14 05:07:37 2014 +0200
@@ -10,21 +10,22 @@
 import psycopg2.extras
 
 from twisted.application import service
+from twisted.internet import reactor
 from twisted.python import log
 from txpostgres import txpostgres
 
 from annotserver import make_service
 import config
-from models import get_table_create_stmt
-from utils import create_connection_pool
+from database import create_connection_pool, init_db, db_session
 
 
 psycopg2.extras.register_uuid()
 
 
+init_db()
 conn, d = create_connection_pool(config.CONN_STR)
 #to do treat error
-d.addCallback(lambda _: conn.runOperation(get_table_create_stmt()))
+#d.addCallback(lambda _: conn.runOperation(get_table_create_stmt()))
 
 #TOODO Log
 #log.startLogging(sys.stdout)
@@ -34,3 +35,5 @@
 
 annotserver = make_service(conn)
 annotserver.setServiceParent(service.IServiceCollection(application))
+
+reactor.addSystemEventTrigger('before', 'shutdown', lambda: db_session.remove())