annot-server/server.tac
changeset 0 e1d4d7a8255a
child 2 fc1ab0074e29
equal deleted inserted replaced
-1:000000000000 0:e1d4d7a8255a
       
     1 
       
     2 #
       
     3 # See LICENCE for detail
       
     4 # Copyright (c) 2014 IRI
       
     5 #
       
     6 
       
     7 import sys
       
     8 
       
     9 import psycopg2.extras
       
    10 
       
    11 from twisted.application import service
       
    12 from twisted.python import log
       
    13 from txpostgres import txpostgres
       
    14 
       
    15 from annotserver import make_service
       
    16 from models import get_table_create_stmt
       
    17 from utils import create_connection_pool
       
    18 
       
    19 #postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
       
    20 
       
    21 psycopg2.extras.register_uuid()
       
    22 
       
    23 
       
    24 config = {
       
    25     'web_port': 8080,
       
    26     'ws_port': 8090,
       
    27     'osc_port': 9090,
       
    28     'conn_str': 'postgresql://iri:iri@localhost:5432/annotations'
       
    29 }
       
    30 
       
    31 
       
    32 conn, d = create_connection_pool(config['conn_str'])
       
    33 #to do treat error
       
    34 d.addCallback(lambda _: conn.runOperation(get_table_create_stmt()))
       
    35 
       
    36 #TOODO Log
       
    37 #log.startLogging(sys.stdout)
       
    38 
       
    39 
       
    40 application = service.Application("annot-server")
       
    41 
       
    42 annotserver = make_service(config, conn)
       
    43 annotserver.setServiceParent(service.IServiceCollection(application))