Revision f154a7a3 daemons/ganeti-watcher
b/daemons/ganeti-watcher | ||
---|---|---|
78 | 78 |
return bool(utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE)) |
79 | 79 |
|
80 | 80 |
|
81 |
def StartMaster():
|
|
82 |
"""Try to start the master daemon.
|
|
81 |
def EnsureDaemon(name):
|
|
82 |
"""Check for and start daemon if not alive.
|
|
83 | 83 |
|
84 | 84 |
""" |
85 |
result = utils.RunCmd(['ganeti-masterd'])
|
|
85 |
result = utils.RunCmd([constants.DAEMON_UTIL, "check-and-start", name])
|
|
86 | 86 |
if result.failed: |
87 |
logging.error("Can't start the master daemon: output '%s'", result.output)
|
|
88 |
return not result.failed
|
|
89 |
|
|
87 |
logging.error("Can't start daemon '%s', failure %s, output: %s",
|
|
88 |
name, result.fail_reason, result.output)
|
|
89 |
return False |
|
90 | 90 |
|
91 |
def EnsureDaemon(daemon): |
|
92 |
"""Check for and start daemon if not alive. |
|
93 |
|
|
94 |
""" |
|
95 |
pidfile = utils.DaemonPidFileName(daemon) |
|
96 |
pid = utils.ReadPidFile(pidfile) |
|
97 |
if pid == 0 or not utils.IsProcessAlive(pid): # no file or dead pid |
|
98 |
logging.debug("Daemon '%s' not alive, trying to restart", daemon) |
|
99 |
result = utils.RunCmd([daemon]) |
|
100 |
if not result: |
|
101 |
logging.error("Can't start daemon '%s', failure %s, output: %s", |
|
102 |
daemon, result.fail_reason, result.output) |
|
91 |
return True |
|
103 | 92 |
|
104 | 93 |
|
105 | 94 |
class WatcherState(object): |
... | ... | |
503 | 492 |
except luxi.NoMasterError, err: |
504 | 493 |
logging.warning("Master seems to be down (%s), trying to restart", |
505 | 494 |
str(err)) |
506 |
if not StartMaster():
|
|
495 |
if not EnsureDaemon(constants.MASTERD):
|
|
507 | 496 |
logging.critical("Can't start the master, exiting") |
508 | 497 |
sys.exit(constants.EXIT_FAILURE) |
509 | 498 |
# else retry the connection |
Also available in: Unified diff