annot-server/server.tac
author ymh <ymh.work@gmail.com>
Fri, 17 Apr 2015 15:20:46 +0200
changeset 165 7dfdafb88968
parent 22 986ee928a866
permissions -rw-r--r--
add ts_server


#
# See LICENCE for detail
# Copyright (c) 2014 IRI
#

import os.path
import sys

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 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()))

#TOODO Log
#log.startLogging(sys.stdout)


application = service.Application("annot-server")

annotserver = make_service(conn)
annotserver.setServiceParent(service.IServiceCollection(application))

reactor.addSystemEventTrigger('before', 'shutdown', lambda: db_session.remove())