Commit dae3fdd2 authored by Guido Trotter's avatar Guido Trotter

Slightly abstract the daemon logfile lookup

The original LOG_<DAEMON_NAME> constants for daemon logfiles are gone.
In their place there is a DAEMONS_LOGFILES dict, indexed by daemon name.

This is a minor change with the objective to uniform most of the
daemon's main() functions code, which is very similar one to the other.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 8c96d01f
......@@ -474,6 +474,7 @@ def main():
options, args = ParseOptions()
utils.no_fork = True
daemon_name = constants.MASTERD
if options.fork:
utils.CloseFDs()
......@@ -511,11 +512,12 @@ def main():
# become a daemon
if options.fork:
utils.Daemonize(logfile=constants.LOG_MASTERDAEMON)
utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
utils.WritePidFile(constants.MASTERD_PID)
try:
utils.SetupLogging(constants.LOG_MASTERDAEMON, debug=options.debug,
utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name],
debug=options.debug,
stderr_logging=not options.fork, multithreaded=True)
logging.info("Ganeti master daemon startup")
......
......@@ -762,6 +762,7 @@ def main():
"""
global queue_lock
daemon_name = constants.NODED
options, args = ParseOptions()
......@@ -782,11 +783,12 @@ def main():
# become a daemon
if options.fork:
utils.Daemonize(logfile=constants.LOG_NODESERVER)
utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
utils.WritePidFile(constants.NODED_PID)
try:
utils.SetupLogging(logfile=constants.LOG_NODESERVER, debug=options.debug,
utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name],
debug=options.debug,
stderr_logging=not options.fork)
logging.info("ganeti node daemon startup")
......
......@@ -225,6 +225,7 @@ def main():
"""
options, args = ParseOptions()
daemon_name = constants.RAPI
if options.fork:
utils.CloseFDs()
......@@ -244,9 +245,9 @@ def main():
port = utils.GetDaemonPort(constants.RAPI)
if options.fork:
utils.Daemonize(logfile=constants.LOG_RAPISERVER)
utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
utils.SetupLogging(constants.LOG_RAPISERVER, debug=options.debug,
utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], debug=options.debug,
stderr_logging=not options.fork)
utils.WritePidFile(constants.RAPI_PID)
......
......@@ -118,6 +118,7 @@ NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
NODED = "ganeti-noded"
RAPI = "ganeti-rapi"
MASTERD = "ganeti-masterd"
DAEMONS_PORTS = {
# daemon-name: ("proto", "default-port")
......@@ -132,11 +133,14 @@ LAST_DRBD_PORT = 14999
MASTER_SCRIPT = "ganeti-master"
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
DAEMONS_LOGFILES = {
# "daemon-name": "logfile"
NODED: LOG_DIR + "node-daemon.log",
RAPI: LOG_DIR + "rapi-daemon.log",
MASTERD: LOG_DIR + "master-daemon.log",
}
LOG_OS_DIR = LOG_DIR + "os"
LOG_NODESERVER = LOG_DIR + "node-daemon.log"
LOG_WATCHER = LOG_DIR + "watcher.log"
LOG_MASTERDAEMON = LOG_DIR + "master-daemon.log"
LOG_RAPISERVER = LOG_DIR + "rapi-daemon.log"
LOG_COMMANDS = LOG_DIR + "commands.log"
LOG_BURNIN = LOG_DIR + "burnin.log"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment