Hi, Am 08.12.19 um 20:20 schrieb Thomas De Schampheleire: > Hi Wolfgang, > > El mié., 4 dic. 2019 a las 2:11, Mads Kiilerich (<m...@kiilerich.com>) > escribió: >> On 12/4/19 1:36 AM, Wolfgang Scherer wrote: >>> When following the instructions for WSGI dispatch at >>> https://kallithea.readthedocs.io/en/latest/setup.html#apache-with-mod-wsgi >>> any attempt to pass defaults to the logging initialization fails later, >>> when logging is initialized again in :func:`make_app` of >>> |kallithea/config/middleware.py|. >>> >>> See >>> http://sw-amt.ws/kallithea-deploy/html/overview.html#bug-logging-re-initialized-in-make-app >>> for a full description of the bug. >>> >>> Attached is a patch, that works for me. >> >> Thanks for the report and patch! >> >> It seems like some different strategies could be: >> >> 1. don't initialize logging in the WSGI script - just rely on what is >> happening in make_app. This is not a good idea, since the administrator may wish to specify run-time configuration defaults. >> >> 2. don't initialize logging in make_app - make sure it is initialized in >> all code paths that end up in make_app ... such as WSGI script and >> kallithea-cli. This is the correct solution. I have checked all initialization pathes: gearbox serve, kallithea-cli, kallithea mod_wsgi (and pserve, paster serve). >> >> Do you have any experience with these alternative approaches ... or >> thoughts about why they might be good or bad? > Any feedback on this?
I finished the analysis of logging initialization (http://sw-amt.ws/kallithea-deploy/html/overview.html#bug-logging-re-initialized-in-make-app). Since I don't think that all the packages will be updated any time soon, I will stay with the minimum required corrections in Kallithea (see attached patch). The initialization schema is generally 1. Initialize logging (each toolkit rolls their own, but defaults :attr:`__file__` and :attr:`here` are always set) 2. Load WSGI application (:func:`paste.deploy.loadapp`) Wolfgang
diff --git a/docs/setup.rst b/docs/setup.rst --- a/docs/setup.rst +++ b/docs/setup.rst @@ -562,7 +562,7 @@ ini = '/srv/kallithea/my.ini' from logging.config import fileConfig - fileConfig(ini) + fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) from paste.deploy import loadapp application = loadapp('config:' + ini) @@ -578,7 +578,7 @@ ini = '/srv/kallithea/kallithea.ini' from logging.config import fileConfig - fileConfig(ini) + fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) from paste.deploy import loadapp application = loadapp('config:' + ini) diff --git a/kallithea/bin/kallithea_cli_base.py b/kallithea/bin/kallithea_cli_base.py --- a/kallithea/bin/kallithea_cli_base.py +++ b/kallithea/bin/kallithea_cli_base.py @@ -72,7 +72,11 @@ path_to_ini_file = os.path.realpath(config_file) kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file) config_bytes = read_config(path_to_ini_file, strip_section_prefix=annotated.__name__) - logging.config.fileConfig(cStringIO.StringIO(config_bytes)) + defaults = { + 'here': os.path.dirname(os.path.abspath(path_to_ini_file)), + '__file__': os.path.abspath(path_to_ini_file) + } + logging.config.fileConfig(cStringIO.StringIO(config_bytes), defaults, disable_existing_loggers=False) if config_file_initialize_app: kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG) diff --git a/kallithea/config/middleware.py b/kallithea/config/middleware.py --- a/kallithea/config/middleware.py +++ b/kallithea/config/middleware.py @@ -49,5 +49,4 @@ ``app_conf`` contains all the application-specific settings (those defined under ``[app:main]``. """ - logging.config.fileConfig(global_conf['__file__']) return make_app_without_logging(global_conf, full_stack=full_stack, **app_conf)
_______________________________________________ kallithea-general mailing list kallithea-general@sfconservancy.org https://lists.sfconservancy.org/mailman/listinfo/kallithea-general