Move WSGI initialization into module
This commit is contained in:
parent
3f9c34c8b1
commit
8b1547cbe5
@ -26,16 +26,8 @@ WSGI-to-FastCGI mapper.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
from flup.server.fcgi import WSGIServer
|
from flup.server.fcgi import WSGIServer
|
||||||
from radicale import Application, config, log
|
from radicale import application
|
||||||
|
|
||||||
|
|
||||||
config_paths = []
|
WSGIServer(application).run()
|
||||||
if os.environ.get("RADICALE_CONFIG"):
|
|
||||||
config_paths.append(os.environ["RADICALE_CONFIG"])
|
|
||||||
configuration = config.load(config_paths, ignore_missing_paths=False)
|
|
||||||
filename = os.path.expanduser(configuration.get("logging", "config"))
|
|
||||||
debug = configuration.getboolean("logging", "debug")
|
|
||||||
logger = log.start("radicale", filename, debug)
|
|
||||||
WSGIServer(Application(configuration, logger)).run()
|
|
||||||
|
@ -21,15 +21,4 @@ Radicale WSGI file (mod_wsgi and uWSGI compliant).
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
from radicale import application
|
||||||
from radicale import Application, config, log
|
|
||||||
|
|
||||||
|
|
||||||
config_paths = []
|
|
||||||
if os.environ.get("RADICALE_CONFIG"):
|
|
||||||
config_paths.append(os.environ["RADICALE_CONFIG"])
|
|
||||||
configuration = config.load(config_paths, ignore_missing_paths=False)
|
|
||||||
filename = os.path.expanduser(configuration.get("logging", "config"))
|
|
||||||
debug = configuration.getboolean("logging", "debug")
|
|
||||||
logger = log.start("radicale", filename, debug)
|
|
||||||
application = Application(configuration, logger)
|
|
||||||
|
@ -51,7 +51,7 @@ from xml.etree import ElementTree as ET
|
|||||||
|
|
||||||
import vobject
|
import vobject
|
||||||
|
|
||||||
from radicale import auth, rights, storage, web, xmlutils
|
from radicale import auth, config, log, rights, storage, web, xmlutils
|
||||||
|
|
||||||
|
|
||||||
VERSION = pkg_resources.get_distribution('radicale').version
|
VERSION = pkg_resources.get_distribution('radicale').version
|
||||||
@ -949,3 +949,25 @@ class Application:
|
|||||||
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
return (status, headers, self._write_xml_content(xml_answer))
|
return (status, headers, self._write_xml_content(xml_answer))
|
||||||
|
|
||||||
|
|
||||||
|
_application = None
|
||||||
|
_application_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
def application(environ, start_response):
|
||||||
|
global _application
|
||||||
|
if _application is None:
|
||||||
|
with _application_lock:
|
||||||
|
if _application is None:
|
||||||
|
config_paths = []
|
||||||
|
if os.environ.get("RADICALE_CONFIG"):
|
||||||
|
config_paths.append(os.environ["RADICALE_CONFIG"])
|
||||||
|
configuration = config.load(config_paths,
|
||||||
|
ignore_missing_paths=False)
|
||||||
|
filename = os.path.expanduser(configuration.get("logging",
|
||||||
|
"config"))
|
||||||
|
debug = configuration.getboolean("logging", "debug")
|
||||||
|
logger = log.start("radicale", filename, debug)
|
||||||
|
_application = Application(configuration, logger)
|
||||||
|
return _application(environ, start_response)
|
||||||
|
Loading…
Reference in New Issue
Block a user