diff options
| author | bwarsaw | 2001-11-21 22:19:42 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-11-21 22:19:42 +0000 |
| commit | d2dd6714c64343ce0e8de7e6bdb94e2cc6d648e2 (patch) | |
| tree | 39b59d180301a5c87653268edd24d521d6082365 | |
| parent | eba2b42a02b7d95cfb43e0a2ba796a55470800bb (diff) | |
| download | mailman-d2dd6714c64343ce0e8de7e6bdb94e2cc6d648e2.tar.gz mailman-d2dd6714c64343ce0e8de7e6bdb94e2cc6d648e2.tar.zst mailman-d2dd6714c64343ce0e8de7e6bdb94e2cc6d648e2.zip | |
Added -s/--subproc switch which subtly, but usefully changes its exit
semantics. When run as a subproc, any ImportErrors caused by bogus
qrunner names simply get logged, and the script exits with an error
code == SIGTERM. This tells mailmanctl not to try to infinitely
restart it.
| -rw-r--r-- | bin/qrunner | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/bin/qrunner b/bin/qrunner index 437545d06..db58d9f55 100644 --- a/bin/qrunner +++ b/bin/qrunner @@ -56,6 +56,11 @@ Options: -v/--verbose Spit out more debugging information to the logs/qrunner log file. + -s/--subproc + This should only be used when running qrunner as a subprocess of the + mailmanctl startup script. It changes some of the exit-on-error + behavior to work better with that framework. + -h/--help Print this message and exit. @@ -76,6 +81,9 @@ from Mailman.Logging.Utils import LogStdErr PROGRAM = sys.argv[0] COMMASPACE = ', ' +# Flag which says whether we're running under mailmanctl or not. +AS_SUBPROC = 0 + LogStdErr('error', 'qrunner', manual_reprime=0, tee_to_stdout=1) @@ -93,7 +101,12 @@ def make_qrunner(name, slice, range, once=0): try: __import__(modulename) except ImportError, e: - usage(1, e) + if AS_SUBPROC: + # Exit with SIGTERM exit code so mailmanctl won't try to restart us + print >> sys.stderr, 'Cannot import runner module', modulename + sys.exit(signal.SIGTERM) + else: + usage(1, e) qrclass = getattr(sys.modules[modulename], name) if once: # Subclass to hack in the setting of the stop flag in _doperiodic() @@ -135,10 +148,11 @@ def set_signals(loop): def main(): + global AS_SUBPROC try: opts, args = getopt.getopt( - sys.argv[1:], 'hlor:v', - ['help', 'list', 'once', 'runner=', 'verbose']) + sys.argv[1:], 'hlor:vs', + ['help', 'list', 'once', 'runner=', 'verbose', 'subproc']) except getopt.error, msg: usage(1, msg) @@ -183,6 +197,8 @@ def main(): runners.append((runner, slice, range)) else: runners.append((runner + 'Runner', slice, range)) + elif opt in ('-s', '--subproc'): + AS_SUBPROC = 1 elif opt in ('-v', '--verbose'): verbose = 1 |
