summaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rw-r--r--server.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/server.py b/server.py
index 9e43de93..eb565e9f 100644
--- a/server.py
+++ b/server.py
@@ -5,17 +5,32 @@ This should be run with:
twistd -n web --wsgi=leap.soledad.server.application
"""
+import configparser
from twisted.web.wsgi import WSGIResource
from twisted.internet import reactor
from u1db.remote import http_app
from leap.soledad.backends.couch import CouchServerState
-# TODO: change couch url accordingly
-couch_url = 'http://localhost:5984'
-state = CouchServerState(couch_url)
+
+def load_configuration(file_path):
+ conf = {
+ 'couch_url': 'http://localhost:5984',
+ 'working_dir': '/tmp',
+ }
+ config = configparser.ConfigParser()
+ config.read(file_path)
+ if 'soledad-server' in config:
+ for key in conf:
+ if key in config['soledad-server']:
+ conf[key] = config['soledad-server'][key]
+ return conf
+
+
+conf = load_configuration('/etc/leap/soledad-server.ini')
+
+state = CouchServerState(conf['couch_url'])
# TODO: change working dir to something meaningful
-state.set_workingdir('/tmp')
-# TODO: write a LeapHTTPApp that will use Couch as backend instead of SQLite
+state.set_workingdir(conf['working_dir'])
application = http_app.HTTPApp(state)
resource = WSGIResource(reactor, reactor.getThreadPool(), application)