Commit 83052f9e authored by Guido Trotter's avatar Guido Trotter
Browse files

Remove <DAEMON>_PID constants



The <DAEMON>_PID constants were created to reference a daemon pid file,
but actually contain a daemon's name, because the various functions that
work with pidfiles abstract the filename from the daemon name
themselves. Removing the constants and using the actual daemon name
constants in their place.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent dae3fdd2
......@@ -514,7 +514,7 @@ def main():
if options.fork:
utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
utils.WritePidFile(constants.MASTERD_PID)
utils.WritePidFile(daemon_name)
try:
utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name],
debug=options.debug,
......@@ -539,7 +539,7 @@ def main():
finally:
rpc.Shutdown()
finally:
utils.RemovePidFile(constants.MASTERD_PID)
utils.RemovePidFile(daemon_name)
utils.RemoveFile(constants.MASTER_SOCKET)
......
......@@ -785,7 +785,7 @@ def main():
if options.fork:
utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
utils.WritePidFile(constants.NODED_PID)
utils.WritePidFile(daemon_name)
try:
utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name],
debug=options.debug,
......@@ -808,7 +808,7 @@ def main():
finally:
server.Stop()
finally:
utils.RemovePidFile(constants.NODED_PID)
utils.RemovePidFile(daemon_name)
if __name__ == '__main__':
......
......@@ -250,7 +250,7 @@ def main():
utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], debug=options.debug,
stderr_logging=not options.fork)
utils.WritePidFile(constants.RAPI_PID)
utils.WritePidFile(daemon_name)
try:
mainloop = daemon.Mainloop()
server = RemoteApiHttpServer(mainloop, options.bind_address, port,
......@@ -263,7 +263,7 @@ def main():
finally:
server.Stop()
finally:
utils.RemovePidFile(constants.RAPI_PID)
utils.RemovePidFile(daemon_name)
if __name__ == '__main__':
......
......@@ -478,9 +478,8 @@ def main():
update_file = False
try:
# on master or not, try to start the node dameon (use _PID but is
# the same as daemon name)
EnsureDaemon(constants.NODED_PID)
# on master or not, try to start the node dameon
EnsureDaemon(constants.NODED)
notepad = WatcherState()
try:
......@@ -500,8 +499,8 @@ def main():
# else retry the connection
client = cli.GetClient()
# we are on master now (use _PID but is the same as daemon name)
EnsureDaemon(constants.RAPI_PID)
# we are on master now
EnsureDaemon(constants.RAPI)
try:
watcher = Watcher(options, notepad)
......
......@@ -298,7 +298,7 @@ def StopMaster(stop_daemons):
if stop_daemons:
# stop/kill the rapi and the master daemon
for daemon in constants.RAPI_PID, constants.MASTERD_PID:
for daemon in constants.RAPI, constants.MASTERD:
utils.KillProcess(utils.ReadPidFile(utils.DaemonPidFileName(daemon)))
......@@ -2280,7 +2280,7 @@ def DemoteFromMC():
master, myself = ssconf.GetMasterAndMyself()
if master == myself:
_Fail("ssconf status shows I'm the master node, will not demote")
pid_file = utils.DaemonPidFileName(constants.MASTERD_PID)
pid_file = utils.DaemonPidFileName(constants.MASTERD)
if utils.IsProcessAlive(utils.ReadPidFile(pid_file)):
_Fail("The master daemon is running, will not demote")
try:
......
......@@ -109,11 +109,6 @@ SYSCONFDIR = _autoconf.SYSCONFDIR
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
# PID files
MASTERD_PID = "ganeti-masterd"
NODED_PID = "ganeti-noded"
RAPI_PID = "ganeti-rapi"
NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
NODED = "ganeti-noded"
......
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