summaryrefslogtreecommitdiff
path: root/src/leap/soledad/server/_wsgi.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/soledad/server/_wsgi.py')
-rw-r--r--src/leap/soledad/server/_wsgi.py34
1 files changed, 7 insertions, 27 deletions
diff --git a/src/leap/soledad/server/_wsgi.py b/src/leap/soledad/server/_wsgi.py
index 510cb7b9..083b00a9 100644
--- a/src/leap/soledad/server/_wsgi.py
+++ b/src/leap/soledad/server/_wsgi.py
@@ -20,16 +20,14 @@ A WSGI application that serves Soledad synchronization.
from twisted.internet import reactor
from twisted.web.wsgi import WSGIResource
+from leap.soledad.server._config import get_config
from leap.soledad.server import SoledadApp
from leap.soledad.server.gzip_middleware import GzipMiddleware
from leap.soledad.common.backend import SoledadBackend
from leap.soledad.common.couch.state import CouchServerState
-from leap.soledad.common.log import getLogger
-from twisted.logger import Logger
-log = Logger()
-__all__ = ['init_couch_state', 'get_sync_resource']
+__all__ = ['get_sync_resource']
def _get_couch_state(conf):
@@ -38,27 +36,9 @@ def _get_couch_state(conf):
return state
-_app = SoledadApp(None) # delay state init
-wsgi_application = GzipMiddleware(_app)
-
-
-# During its initialization, the couch state verifies if all user databases
-# contain a config document with the correct couch schema version stored, and
-# will log an error and raise an exception if that is not the case.
-#
-# If this verification made too early (i.e. before the reactor has started and
-# the twistd web logging facilities have been setup), the logging will not
-# work. Because of that, we delay couch state initialization until the reactor
-# is running.
-
-def init_couch_state(conf):
- try:
- _app.state = _get_couch_state(conf)
- except Exception as e:
- logger = getLogger()
- logger.error(str(e))
- reactor.stop()
-
-
def get_sync_resource(pool):
- return WSGIResource(reactor, pool, wsgi_application)
+ conf = get_config()
+ state = _get_couch_state(conf)
+ app = SoledadApp(state)
+ wsgi_app = GzipMiddleware(app)
+ return WSGIResource(reactor, pool, wsgi_app)