Revision 8cabf472 lib/daemon.py

b/lib/daemon.py
40 40
from ganeti import netutils
41 41
from ganeti import ssconf
42 42
from ganeti import runtime
43
from ganeti import compat
43 44

  
44 45

  
45 46
class SchedulerBreakout(Exception):
......
539 540
    return "%s" % str(err)
540 541

  
541 542

  
543
def _HandleSigHup(reopen_cb, signum, frame): # pylint: disable-msg=W0613
544
  """Handler for SIGHUP.
545

  
546
  @param reopen_cb: Callback function for reopening log files
547

  
548
  """
549
  assert callable(reopen_cb)
550
  logging.info("Reopening log files after receiving SIGHUP")
551
  reopen_cb()
552

  
553

  
542 554
def GenericMain(daemon_name, optionparser,
543 555
                check_fn, prepare_fn, exec_fn,
544 556
                multithreaded=False, console_logging=False,
......
656 668
  else:
657 669
    wpipe = None
658 670

  
671
  log_reopen_fn = \
672
    utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], daemon_name,
673
                       debug=options.debug,
674
                       stderr_logging=not options.fork,
675
                       multithreaded=multithreaded,
676
                       syslog=options.syslog,
677
                       console_logging=console_logging)
678

  
679
  # Reopen log file(s) on SIGHUP
680
  signal.signal(signal.SIGHUP, compat.partial(_HandleSigHup, log_reopen_fn))
681

  
659 682
  utils.WritePidFile(utils.DaemonPidFileName(daemon_name))
660 683
  try:
661 684
    try:
662
      utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], daemon_name,
663
                         debug=options.debug,
664
                         stderr_logging=not options.fork,
665
                         multithreaded=multithreaded,
666
                         syslog=options.syslog,
667
                         console_logging=console_logging)
668 685
      if callable(prepare_fn):
669 686
        prep_results = prepare_fn(options, args)
670 687
      else:

Also available in: Unified diff