Commit 3dda3f51 authored by David Douard's avatar David Douard
Browse files

Allow to override config file options by cmdline arguments (closes #5724484)

For the sake of consistency with cw, the 'profile' option's short name has
been removed, so we can use the lower 'p' for this purpose (for consistency
with cubicweb).

Requires CubicWeb 3.21 to work.
parent aa215726817d
......@@ -15,6 +15,7 @@ import threading
import subprocess
from cubicweb import BadCommandUsage, ExecutionError
from cubicweb.__pkginfo__ import numversion as cwversion
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold
......@@ -58,7 +59,7 @@ class PyramidStartHandler(InstanceCommand):
'help': 'debug if -D is set, error otherwise',
}),
('profile',
{'short': 'p', 'action': 'store_true',
{'action': 'store_true',
'default': False,
'help': 'Enable profiling'}),
('profile-output',
......@@ -72,6 +73,14 @@ class PyramidStartHandler(InstanceCommand):
'help': 'Dump profile stats to ouput every N requests '
'(default: 100)'}),
)
if cwversion >= (3, 21, 0):
options = PyramidStartHandler.options + (
('param',
{'short': 'p', 'type': 'named', 'metavar': 'key1:value1,key2:value2',
'default': {},
'help': 'override <key> configuration file option with <value>.',
}),
)
_reloader_environ_key = 'CW_RELOADER_SHOULD_RUN'
_reloader_filelist_environ_key = 'CW_RELOADER_FILELIST'
......@@ -278,7 +287,8 @@ class PyramidStartHandler(InstanceCommand):
return self.restart_with_reloader()
cwconfig = cwcfg.config_for(appid, debugmode=debugmode)
if cwversion >= (3, 21, 0):
cwconfig.cmdline_options = self.config.param
if autoreload:
_turn_sigterm_into_systemexit()
self.debug('Running reloading file monitor')
......@@ -296,15 +306,14 @@ class PyramidStartHandler(InstanceCommand):
init_cmdline_log_threshold(cwconfig, self['loglevel'])
host = cwconfig['interface']
port = cwconfig['port'] or 8080
app = wsgi_application_from_cwconfig(
cwconfig, profile=self['profile'],
profile_output=self['profile-output'],
profile_dump_every=self['profile-dump-every']
)
host = cwconfig['interface']
port = cwconfig['port'] or 8080
repo = cwconfig.repository()
try:
repo.start_looping_tasks()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment