221 |
221 |
self._signal_wait.append(owner)
|
222 |
222 |
|
223 |
223 |
|
224 |
|
def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn):
|
|
224 |
def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn,
|
|
225 |
multithreaded=False):
|
225 |
226 |
"""Shared main function for daemons.
|
226 |
227 |
|
227 |
228 |
@type daemon_name: string
|
... | ... | |
237 |
238 |
@type exec_fn: function which accepts (options, args)
|
238 |
239 |
@param exec_fn: function that's executed with the daemon's pid file held, and
|
239 |
240 |
runs the daemon itself.
|
|
241 |
@type multithreaded: bool
|
|
242 |
@param multithreaded: Whether the daemon uses threads
|
240 |
243 |
|
241 |
244 |
"""
|
242 |
245 |
optionparser.add_option("-f", "--foreground", dest="fork",
|
... | ... | |
271 |
274 |
help="SSL certificate",
|
272 |
275 |
default=default_cert, type="string")
|
273 |
276 |
|
274 |
|
multithread = utils.no_fork = daemon_name in constants.MULTITHREADED_DAEMONS
|
|
277 |
# Disable the use of fork(2) if the daemon uses threads
|
|
278 |
utils.no_fork = multithreaded
|
275 |
279 |
|
276 |
280 |
options, args = optionparser.parse_args()
|
277 |
281 |
|
... | ... | |
298 |
302 |
utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name],
|
299 |
303 |
debug=options.debug,
|
300 |
304 |
stderr_logging=not options.fork,
|
301 |
|
multithreaded=multithread)
|
|
305 |
multithreaded=multithreaded)
|
302 |
306 |
logging.info("%s daemon startup", daemon_name)
|
303 |
307 |
exec_fn(options, args)
|
304 |
308 |
finally:
|