Revision 8cabf472

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:
b/lib/utils/log.py
200 200
  @param root_logger: Root logger to use (for unittests)
201 201
  @raise EnvironmentError: if we can't open the log file and
202 202
      syslog/stderr logging is disabled
203
  @rtype: callable
204
  @return: Function reopening all open log files when called
203 205

  
204 206
  """
205 207
  progname = os.path.basename(program)
b/man/ganeti.rst
172 172

  
173 173
The option ``--priority`` sets the priority for opcodes submitted
174 174
by the command.
175

  
176

  
177
Common daemon functionality
178
---------------------------
179

  
180
All Ganeti daemons re-open the log file(s) when sent a SIGHUP signal.
181
**logrotate**(8) can be used to rotate Ganeti's log files.

Also available in: Unified diff