diff options
author | drebs <drebs@leap.se> | 2013-02-19 20:33:04 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-02-19 20:33:04 -0300 |
commit | 8b4b10b273877e9c41a1638c789aafde5ebebedf (patch) | |
tree | e573eb30b8a642159d54460c756f3c79b77cdf49 /server.py | |
parent | 92bd7132c22b422039d2c1cfac42bec30e317d5d (diff) |
Add ability on server to read configuration from file.
Diffstat (limited to 'server.py')
-rw-r--r-- | server.py | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -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) |