annot-server/server.tac
changeset 2 fc1ab0074e29
parent 0 e1d4d7a8255a
child 3 1b94e6e9579f
equal deleted inserted replaced
1:1cdebfeb77f9 2:fc1ab0074e29
     2 #
     2 #
     3 # See LICENCE for detail
     3 # See LICENCE for detail
     4 # Copyright (c) 2014 IRI
     4 # Copyright (c) 2014 IRI
     5 #
     5 #
     6 
     6 
       
     7 import os.path
     7 import sys
     8 import sys
     8 
     9 
     9 import psycopg2.extras
    10 import psycopg2.extras
    10 
    11 
    11 from twisted.application import service
    12 from twisted.application import service
    12 from twisted.python import log
    13 from twisted.python import log
    13 from txpostgres import txpostgres
    14 from txpostgres import txpostgres
    14 
    15 
    15 from annotserver import make_service
    16 from annotserver import make_service
       
    17 frpm config import config
    16 from models import get_table_create_stmt
    18 from models import get_table_create_stmt
    17 from utils import create_connection_pool
    19 from utils import create_connection_pool
    18 
    20 
    19 #postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
       
    20 
    21 
    21 psycopg2.extras.register_uuid()
    22 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 
    23 
    31 
    24 
    32 conn, d = create_connection_pool(config['conn_str'])
    25 conn, d = create_connection_pool(config['conn_str'])
    33 #to do treat error
    26 #to do treat error
    34 d.addCallback(lambda _: conn.runOperation(get_table_create_stmt()))
    27 d.addCallback(lambda _: conn.runOperation(get_table_create_stmt()))