Revision 110f49ef

b/lib/daemon.py
544 544
    return "%s" % str(err)
545 545

  
546 546

  
547
def _HandleSigHup(reopen_cb, signum, frame): # pylint: disable-msg=W0613
547
def _HandleSigHup(reopen_fn, signum, frame): # pylint: disable-msg=W0613
548 548
  """Handler for SIGHUP.
549 549

  
550
  @param reopen_cb: Callback function for reopening log files
550
  @param reopen_fn: List of callback functions for reopening log files
551 551

  
552 552
  """
553
  assert callable(reopen_cb)
554 553
  logging.info("Reopening log files after receiving SIGHUP")
555
  reopen_cb()
554

  
555
  for fn in reopen_fn:
556
    if fn:
557
      fn()
556 558

  
557 559

  
558 560
def GenericMain(daemon_name, optionparser,
......
668 670

  
669 671
  if options.fork:
670 672
    utils.CloseFDs()
671
    wpipe = utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
673
    (wpipe, stdio_reopen_fn) = \
674
      utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
672 675
  else:
673
    wpipe = None
676
    (wpipe, stdio_reopen_fn) = (None, None)
674 677

  
675 678
  log_reopen_fn = \
676 679
    utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], daemon_name,
......
681 684
                       console_logging=console_logging)
682 685

  
683 686
  # Reopen log file(s) on SIGHUP
684
  signal.signal(signal.SIGHUP, compat.partial(_HandleSigHup, log_reopen_fn))
687
  signal.signal(signal.SIGHUP,
688
                compat.partial(_HandleSigHup, [log_reopen_fn, stdio_reopen_fn]))
685 689

  
686 690
  utils.WritePidFile(utils.DaemonPidFileName(daemon_name))
687 691
  try:
b/lib/utils/process.py
36 36

  
37 37
from ganeti import errors
38 38
from ganeti import constants
39
from ganeti import compat
39 40

  
40 41
from ganeti.utils import retry as utils_retry
41 42
from ganeti.utils import wrapper as utils_wrapper
......
835 836

  
836 837
  @type logfile: str
837 838
  @param logfile: the logfile to which we should redirect stdout/stderr
838
  @rtype: int
839
  @return: the value zero
839
  @rtype: tuple; (int, callable)
840
  @return: File descriptor of pipe(2) which must be closed to notify parent
841
    process and a callable to reopen log files
840 842

  
841 843
  """
842 844
  # pylint: disable-msg=W0212
......
872 874
      rcode = 0
873 875
    os._exit(rcode) # Exit parent of the first child.
874 876

  
875
  SetupDaemonFDs(logfile, None)
876
  return wpipe
877
  reopen_fn = compat.partial(SetupDaemonFDs, logfile, None)
878

  
879
  # Open logs for the first time
880
  reopen_fn()
881

  
882
  return (wpipe, reopen_fn)
877 883

  
878 884

  
879 885
def KillProcess(pid, signal_=signal.SIGTERM, timeout=30,

Also available in: Unified diff