18 |
18 |
19 from cubicweb import BadCommandUsage, ExecutionError |
19 from cubicweb import BadCommandUsage, ExecutionError |
20 from cubicweb.__pkginfo__ import numversion as cwversion |
20 from cubicweb.__pkginfo__ import numversion as cwversion |
21 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg |
21 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg |
22 from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold |
22 from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold |
|
23 from cubicweb.server import set_debug |
23 |
24 |
24 from pyramid_cubicweb import wsgi_application_from_cwconfig |
25 from pyramid_cubicweb import wsgi_application_from_cwconfig |
25 import waitress |
26 import waitress |
26 |
27 |
27 MAXFD = 1024 |
28 MAXFD = 1024 |
28 |
29 |
|
30 DBG_FLAGS = ('RQL', 'SQL', 'REPO', 'HOOKS', 'OPS', 'SEC', 'MORE') |
|
31 LOG_LEVELS = ('debug', 'info', 'warning', 'error') |
29 |
32 |
30 class PyramidStartHandler(InstanceCommand): |
33 class PyramidStartHandler(InstanceCommand): |
31 """Start an interactive pyramid server. |
34 """Start an interactive pyramid server. |
32 |
35 |
33 This command requires http://hg.logilab.org/review/pyramid_cubicweb/ |
36 This command requires http://hg.logilab.org/review/pyramid_cubicweb/ |
55 ('reload-interval', |
58 ('reload-interval', |
56 {'type': 'int', 'default': 1, |
59 {'type': 'int', 'default': 1, |
57 'help': 'Interval, in seconds, between file modifications checks'}), |
60 'help': 'Interval, in seconds, between file modifications checks'}), |
58 ('loglevel', |
61 ('loglevel', |
59 {'short': 'l', 'type': 'choice', 'metavar': '<log level>', |
62 {'short': 'l', 'type': 'choice', 'metavar': '<log level>', |
60 'default': None, 'choices': ('debug', 'info', 'warning', 'error'), |
63 'default': None, 'choices': LOG_LEVELS, |
61 'help': 'debug if -D is set, error otherwise', |
64 'help': 'debug if -D is set, error otherwise; one of %s' % (LOG_LEVELS,), |
|
65 }), |
|
66 ('dbglevel', |
|
67 {'type': 'multiple_choice', 'metavar': '<dbg level>', |
|
68 'default': None, |
|
69 'choices': DBG_FLAGS, |
|
70 'help': ('Set the server debugging flags; you may choose several ' |
|
71 'values in %s; imply "debug" loglevel' % (DBG_FLAGS,)), |
62 }), |
72 }), |
63 ('profile', |
73 ('profile', |
64 {'action': 'store_true', |
74 {'action': 'store_true', |
65 'default': False, |
75 'default': False, |
66 'help': 'Enable profiling'}), |
76 'help': 'Enable profiling'}), |
304 |
314 |
305 if daemonize: |
315 if daemonize: |
306 self.daemonize(cwconfig['pid-file']) |
316 self.daemonize(cwconfig['pid-file']) |
307 self.record_pid(cwconfig['pid-file']) |
317 self.record_pid(cwconfig['pid-file']) |
308 |
318 |
|
319 if self['dbglevel']: |
|
320 self['loglevel'] = 'debug' |
|
321 set_debug('|'.join('DBG_'+ x.upper() for x in self['dbglevel'])) |
309 init_cmdline_log_threshold(cwconfig, self['loglevel']) |
322 init_cmdline_log_threshold(cwconfig, self['loglevel']) |
310 |
323 |
311 app = wsgi_application_from_cwconfig( |
324 app = wsgi_application_from_cwconfig( |
312 cwconfig, profile=self['profile'], |
325 cwconfig, profile=self['profile'], |
313 profile_output=self['profile-output'], |
326 profile_output=self['profile-output'], |