Revision 3b1b0cb6 lib/daemon.py
b/lib/daemon.py | ||
---|---|---|
22 | 22 |
"""Module with helper classes and functions for daemons""" |
23 | 23 |
|
24 | 24 |
|
25 |
import os |
|
25 | 26 |
import select |
26 | 27 |
import signal |
27 | 28 |
import errno |
... | ... | |
339 | 340 |
help="Bind address", |
340 | 341 |
default="", metavar="ADDRESS") |
341 | 342 |
|
343 |
if daemon_name in constants.DAEMONS_SSL: |
|
344 |
default_cert, default_key = constants.DAEMONS_SSL[daemon_name] |
|
345 |
optionparser.add_option("--no-ssl", dest="ssl", |
|
346 |
help="Do not secure HTTP protocol with SSL", |
|
347 |
default=True, action="store_false") |
|
348 |
optionparser.add_option("-K", "--ssl-key", dest="ssl_key", |
|
349 |
help="SSL key", |
|
350 |
default=default_key, type="string") |
|
351 |
optionparser.add_option("-C", "--ssl-cert", dest="ssl_cert", |
|
352 |
help="SSL certificate", |
|
353 |
default=default_cert, type="string") |
|
354 |
|
|
342 | 355 |
multithread = utils.no_fork = daemon_name in constants.MULTITHREADED_DAEMONS |
343 | 356 |
|
344 | 357 |
options, args = optionparser.parse_args() |
345 | 358 |
|
346 |
check_fn(options, args) |
|
359 |
if hasattr(options, 'ssl') and options.ssl: |
|
360 |
if not (options.ssl_cert and options.ssl_key): |
|
361 |
print >> sys.stderr, "Need key and certificate to use ssl" |
|
362 |
sys.exit(constants.EXIT_FAILURE) |
|
363 |
for fname in (options.ssl_cert, options.ssl_key): |
|
364 |
if not os.path.isfile(fname): |
|
365 |
print >> sys.stderr, "Need ssl file %s to run" % fname |
|
366 |
sys.exit(constants.EXIT_FAILURE) |
|
367 |
|
|
368 |
if check_fn is not None: |
|
369 |
check_fn(options, args) |
|
370 |
|
|
347 | 371 |
utils.EnsureDirs(dirs) |
348 | 372 |
|
349 | 373 |
if options.fork: |
Also available in: Unified diff