From 7bda8b8396756eeaf6635a0183372a9962f51c53 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 13 Nov 2017 22:54:06 -0200 Subject: [bug] remove unneeded delayed initialization of couch state --- src/leap/soledad/server/_wsgi.py | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'src/leap/soledad/server/_wsgi.py') 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) -- cgit v1.2.3