annot-server/server.tac
changeset 0 e1d4d7a8255a
child 2 fc1ab0074e29
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/annot-server/server.tac	Wed Oct 08 15:14:58 2014 +0200
@@ -0,0 +1,43 @@
+
+#
+# See LICENCE for detail
+# Copyright (c) 2014 IRI
+#
+
+import sys
+
+import psycopg2.extras
+
+from twisted.application import service
+from twisted.python import log
+from txpostgres import txpostgres
+
+from annotserver import make_service
+from models import get_table_create_stmt
+from utils import create_connection_pool
+
+#postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
+
+psycopg2.extras.register_uuid()
+
+
+config = {
+    'web_port': 8080,
+    'ws_port': 8090,
+    'osc_port': 9090,
+    'conn_str': 'postgresql://iri:iri@localhost:5432/annotations'
+}
+
+
+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(config, conn)
+annotserver.setServiceParent(service.IServiceCollection(application))