From 8691ba8086348795fc70b8afce0f5ef6f94182b9 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 16 Sep 2014 13:13:00 +0100 Subject: [PATCH] Allow pecan debug middleware to be turned off The Pecan DebugMiddleware is turned on or off based on the ceilometer.conf-wide debug setting. This is not useful for situations where running ceilometer-api under mod_wsgi with multiple processes is desired. This change adds a pecan_debug setting to the api section of config, defaulting to the DEFAULT debug value. mod_wsgi install docs updated accordingly. Configuration docs have not yet been udpated. They will be pending a fix to bug 1370030 Closes-Bug: #1370009 Change-Id: Ib4a472e3c8d1f34f64a5f3ab993c1211dee8af9a --- ceilometer/api/app.py | 13 +++++++++++-- doc/source/install/mod_wsgi.rst | 10 +++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ceilometer/api/app.py b/ceilometer/api/app.py index 9067eaf15..8e8b22eda 100644 --- a/ceilometer/api/app.py +++ b/ceilometer/api/app.py @@ -40,8 +40,17 @@ auth_opts = [ ), ] +api_opts = [ + cfg.BoolOpt('pecan_debug', + default='$debug', + help='Toggle Pecan Debug Middleware. ' + 'Defaults to global debug value.' + ), +] + CONF = cfg.CONF CONF.register_opts(auth_opts) +CONF.register_opts(api_opts, group='api') def get_pecan_config(): @@ -70,7 +79,7 @@ def setup_app(pecan_config=None, extra_hooks=None): pecan_config.app.root, static_root=pecan_config.app.static_root, template_path=pecan_config.app.template_path, - debug=CONF.debug, + debug=CONF.api.pecan_debug, force_canonical=getattr(pecan_config.app, 'force_canonical', True), hooks=app_hooks, wrap_app=middleware.ParsableErrorMiddleware, @@ -83,7 +92,7 @@ def setup_app(pecan_config=None, extra_hooks=None): class VersionSelectorApplication(object): def __init__(self): pc = get_pecan_config() - pc.app.debug = CONF.debug + pc.app.debug = CONF.api.pecan_debug def not_found(environ, start_response): start_response('404 Not Found', []) diff --git a/doc/source/install/mod_wsgi.rst b/doc/source/install/mod_wsgi.rst index 950978ba0..2defcb53a 100644 --- a/doc/source/install/mod_wsgi.rst +++ b/doc/source/install/mod_wsgi.rst @@ -60,10 +60,6 @@ Limitation As Ceilometer is using Pecan and Pecan's DebugMiddleware doesn't support multiple processes, there is no way to set debug mode in the multiprocessing -case. So user will run into HTTP 500 error if the mod_wsgi's multiprocessing -is enabled and the Ceilometer debug mode is enabled at the same time. There -is no good way to make both of them work, since Pecan is sharing the debug -mode with Ceilometer, see[1]. If you really need to enable both, a possible -workaround is hacking that line and hardcode the debug configration to False. - -[1] https://github.com/openstack/ceilometer/blob/master/ceilometer/api/app.py +case. To allow multiple processes the DebugMiddleware may be turned off by +setting ``pecan_debug`` to ``False`` in the ``api`` section of +``ceilometer.conf``.