summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/soledad/server/_wsgi.py34
-rw-r--r--src/leap/soledad/server/server.tac4
2 files changed, 8 insertions, 30 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)
diff --git a/src/leap/soledad/server/server.tac b/src/leap/soledad/server/server.tac
index f6f784bc..3737e7df 100644
--- a/src/leap/soledad/server/server.tac
+++ b/src/leap/soledad/server/server.tac
@@ -23,8 +23,7 @@ from twisted.web import server
from leap.soledad.common.couch.check import check_schema_versions
from leap.soledad.server import entrypoints
-from leap.soledad.server._wsgi import init_couch_state
-from leap.soledad.server._config import get_config
+from leap.soledad.server import get_config
logger = Logger(__name__)
@@ -113,7 +112,6 @@ def _run(application):
_check_env(local_port, public_port)
_check_conf(conf)
d = check_schema_versions(conf['couch_url'])
- d.addCallback(lambda _: init_couch_state(conf))
d.addCallback(lambda _: _create_services(local_port, public_port,
application))