Commit 2826b361 authored by Guido Trotter's avatar Guido Trotter
Browse files

Move watcher's EnsureDaemon function to utils



This is going to be used from the nbma repository, to ensure that the
nld daemon is running.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 1f7d3f7d
......@@ -71,27 +71,14 @@ def ShouldPause():
return bool(utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE))
def EnsureDaemon(name):
"""Check for and start daemon if not alive.
"""
result = utils.RunCmd([constants.DAEMON_UTIL, "check-and-start", name])
if result.failed:
logging.error("Can't start daemon '%s', failure %s, output: %s",
name, result.fail_reason, result.output)
return False
return True
def StartNodeDaemons():
"""Start all the daemons that should be running on all nodes.
"""
# on master or not, try to start the node dameon
EnsureDaemon(constants.NODED)
utils.EnsureDaemon(constants.NODED)
# start confd as well. On non candidates it will be in disabled mode.
EnsureDaemon(constants.CONFD)
utils.EnsureDaemon(constants.CONFD)
def RunWatcherHooks():
......@@ -527,14 +514,14 @@ def main():
except luxi.NoMasterError, err:
logging.warning("Master seems to be down (%s), trying to restart",
str(err))
if not EnsureDaemon(constants.MASTERD):
if not utils.EnsureDaemon(constants.MASTERD):
logging.critical("Can't start the master, exiting")
sys.exit(constants.EXIT_FAILURE)
# else retry the connection
client = cli.GetClient()
# we are on master now
EnsureDaemon(constants.RAPI)
utils.EnsureDaemon(constants.RAPI)
try:
watcher = Watcher(options, notepad)
......
......@@ -1610,6 +1610,19 @@ def DaemonPidFileName(name):
return os.path.join(constants.RUN_GANETI_DIR, "%s.pid" % name)
def EnsureDaemon(name):
"""Check for and start daemon if not alive.
"""
result = RunCmd([constants.DAEMON_UTIL, "check-and-start", name])
if result.failed:
logging.error("Can't start daemon '%s', failure %s, output: %s",
name, result.fail_reason, result.output)
return False
return True
def WritePidFile(name):
"""Write the current process pidfile.
......
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