Skip to content
Snippets Groups Projects
Commit 15486fa7 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ganeti-masterd: Remove PID file at the end

Removing the PID file should be the last thing done. This patch makes
sure it's also removed when master.server_cleanup() throws an exception.

Also initialize logging only after writing the PID file.

Reviewed-by: iustinp
parent 4331f6cd
No related branches found
No related tags found
No related merge requests found
......@@ -446,27 +446,28 @@ def main():
noclose_fds=[master.fileno()])
utils.WritePidFile(constants.MASTERD_PID)
utils.SetupLogging(constants.LOG_MASTERDAEMON, debug=options.debug,
stderr_logging=not options.fork)
rpc.Init()
try:
logging.info("ganeti master daemon startup")
utils.SetupLogging(constants.LOG_MASTERDAEMON, debug=options.debug,
stderr_logging=not options.fork)
# activate ip
master_node = ssconf.SimpleConfigReader().GetMasterNode()
if not rpc.RpcRunner.call_node_start_master(master_node, False):
logging.error("Can't activate master IP address")
logging.info("Ganeti master daemon startup")
master.setup_queue()
rpc.Init()
try:
master.serve_forever()
# activate ip
master_node = ssconf.SimpleConfigReader().GetMasterNode()
if not rpc.RpcRunner.call_node_start_master(master_node, False):
logging.error("Can't activate master IP address")
master.setup_queue()
try:
master.serve_forever()
finally:
master.server_cleanup()
finally:
master.server_cleanup()
utils.RemovePidFile(constants.MASTERD_PID)
rpc.Shutdown()
finally:
rpc.Shutdown()
utils.RemovePidFile(constants.MASTERD_PID)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment