This makes almost all of the daemons show error messages, and not return
until they finished listening on the appropriate sockets.
Masterd is the only one "special", as it doesn't do enough
initialization in the server creation, only later.
---
daemons/ganeti-confd | 15 ++++++++++++---
daemons/ganeti-masterd | 14 +++++++++++---
daemons/ganeti-noded | 13 ++++++++++---
daemons/ganeti-rapi | 13 ++++++++++---
4 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/daemons/ganeti-confd b/daemons/ganeti-confd
index 45d3cdb..0f5de4f 100755
--- a/daemons/ganeti-confd
+++ b/daemons/ganeti-confd
@@ -258,12 +258,13 @@ def CheckConfd(_, args):
# conflict with that. If so, we might warn or EXIT_FAILURE.
-def ExecConfd(options, _dummy1, _dummy2):
- """Main confd function, executed with PID file held
+def PrepConfd(options, _):
+ """Prep confd function, executed with PID file held
"""
# TODO: clarify how the server and reloader variables work (they are
# not used)
+
# pylint: disable-msg=W0612
mainloop = daemon.Mainloop()
@@ -281,6 +282,14 @@ def ExecConfd(options, _dummy1, _dummy2):
# Configuration reloader
reloader = ConfdConfigurationReloader(processor, mainloop)
+ return mainloop
+
+
+def ExecConfd(options, args, prep_data): # pylint: disable-msg=W0613
+ """Main confd function, executed with PID file held
+
+ """
+ mainloop = prep_data
mainloop.Run()
@@ -293,7 +302,7 @@ def main():
version="%%prog (ganeti) %s" %
constants.RELEASE_VERSION)
- daemon.GenericMain(constants.CONFD, parser, CheckConfd, None, ExecConfd)
+ daemon.GenericMain(constants.CONFD, parser, CheckConfd, PrepConfd, ExecConfd)
if __name__ == "__main__":
diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 2e571b9..6c9471e 100755
--- a/daemons/ganeti-masterd
+++ b/daemons/ganeti-masterd
@@ -530,8 +530,8 @@ def CheckMasterd(options, args):
utils.RunInSeparateProcess(ActivateMasterIP)
-def ExecMasterd(options, args, _): # pylint: disable-msg=W0613
- """Main master daemon function, executed with the PID file held.
+def PrepMasterd(options, _):
+ """Prep master daemon function, executed with the PID file held.
"""
# This is safe to do as the pid file guarantees against
@@ -541,6 +541,14 @@ def ExecMasterd(options, args, _): # pylint:
disable-msg=W0613
mainloop = daemon.Mainloop()
master = MasterServer(mainloop, constants.MASTER_SOCKET,
options.uid, options.gid)
+ return (mainloop, master)
+
+
+def ExecMasterd(options, args, prep_data): # pylint: disable-msg=W0613
+ """Main master daemon function, executed with the PID file held.
+
+ """
+ (mainloop, master) = prep_data
try:
rpc.Init()
try:
@@ -568,7 +576,7 @@ def main():
parser.add_option("--yes-do-it", dest="yes_do_it",
help="Override interactive check for --no-voting",
default=False, action="store_true")
- daemon.GenericMain(constants.MASTERD, parser, CheckMasterd, None,
+ daemon.GenericMain(constants.MASTERD, parser, CheckMasterd, PrepMasterd,
ExecMasterd, multithreaded=True)
diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 819bad7..83177fe 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -914,8 +914,8 @@ def CheckNoded(_, args):
sys.exit(constants.EXIT_FAILURE)
-def ExecNoded(options, _dummy1, _dummy2):
- """Main node daemon function, executed with the PID file held.
+def PrepNoded(options, _):
+ """Preparation node daemon function, executed with the PID file held.
"""
if options.mlock:
@@ -947,6 +947,13 @@ def ExecNoded(options, _dummy1, _dummy2):
ssl_params=ssl_params, ssl_verify_peer=True,
request_executor_class=request_executor_class)
server.Start()
+ return (mainloop, server)
+
+def ExecNoded(options, args, prep_data): # pylint: disable-msg=W0613
+ """Main node daemon function, executed with the PID file held.
+
+ """
+ (mainloop, server) = prep_data
try:
mainloop.Run()
finally:
@@ -965,7 +972,7 @@ def main():
help="Do not mlock the node memory in ram",
default=True, action="store_false")
- daemon.GenericMain(constants.NODED, parser, CheckNoded, None, ExecNoded,
+ daemon.GenericMain(constants.NODED, parser, CheckNoded, PrepNoded, ExecNoded,
default_ssl_cert=constants.NODED_CERT_FILE,
default_ssl_key=constants.NODED_CERT_FILE,
console_logging=True)
diff --git a/daemons/ganeti-rapi b/daemons/ganeti-rapi
index f861a0b..5251652 100755
--- a/daemons/ganeti-rapi
+++ b/daemons/ganeti-rapi
@@ -280,8 +280,8 @@ def CheckRapi(options, args):
options.ssl_params = None
-def ExecRapi(options, _dummy1, _dummy2):
- """Main remote API function, executed with the PID file held.
+def PrepRapi(options, _):
+ """Prep remote API function, executed with the PID file held.
"""
@@ -301,6 +301,13 @@ def ExecRapi(options, _dummy1, _dummy2):
# pylint: disable-msg=E1101
# it seems pylint doesn't see the second parent class there
server.Start()
+ return (mainloop, server)
+
+def ExecRapi(options, args, prep_data): # pylint: disable-msg=W0613
+ """Main remote API function, executed with the PID file held.
+
+ """
+ (mainloop, server) = prep_data
try:
mainloop.Run()
finally:
@@ -315,7 +322,7 @@ def main():
usage="%prog [-f] [-d] [-p port] [-b ADDRESS]",
version="%%prog (ganeti) %s" % constants.RELEASE_VERSION)
- daemon.GenericMain(constants.RAPI, parser, CheckRapi, None, ExecRapi,
+ daemon.GenericMain(constants.RAPI, parser, CheckRapi, PrepRapi, ExecRapi,
default_ssl_cert=constants.RAPI_CERT_FILE,
default_ssl_key=constants.RAPI_CERT_FILE)
--
1.7.1