1 Ganeti uses an internal tool to start/stop daemons during init and
2 upgrade. This patch makes the tool use native Shepherd facilities.
4 diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
5 --- a/daemons/daemon-util.in
6 +++ b/daemons/daemon-util.in
7 @@ -184,6 +184,21 @@ use_systemctl() {
11 +# Checks if we should use the Shepherd to start/stop daemons
13 + # Is Shepherd running as PID 1?
14 + ps --no-headers -p 1 -o cmd | grep -q shepherd || return 1
16 + type -p herd >/dev/null || return 1
18 + # Does Shepherd know about Ganeti at all?
19 + if herd status | grep -q ganeti; then
26 # Prints path to PID file for a daemon.
28 if [[ "$#" -lt 1 ]]; then
29 @@ -261,6 +276,13 @@ check() {
33 + elif use_shepherd; then
34 + activestate="$(herd status ${name})"
35 + if echo $activestate | grep -q Running ; then
40 elif type -p start-stop-daemon >/dev/null; then
41 start-stop-daemon --stop --signal 0 --quiet \
42 --pidfile $pidfile --name "$name"
43 @@ -291,6 +313,20 @@ start() {
47 + if use_shepherd; then
48 + if herd status "$name" | grep -q "disabled"; then
49 + # The Shepherd will disable a service that has stopped, even if it exits
50 + # gracefully. Thus, we must re-enable it in case of a master failover.
51 + herd enable "${name}"
53 + # Note: unlike systemd, which happily starts a service and returns success
54 + # even if the daemon immediately exits, the Shepherd actually waits for it
55 + # to come up. Thus, ignore the exit status from 'herd start' in case of
56 + # master daemons running on the wrong node, or ganeti-kvmd disabled, etc.
57 + herd start "${name}"
61 # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
62 eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""
64 @@ -336,6 +372,13 @@ stop() {
66 if use_systemctl; then
67 systemctl stop "${name}.service"
68 + elif use_shepherd; then
69 + if herd status | grep -q "$name"; then
72 + # Do not raise an error if the service has not been enabled.
75 elif type -p start-stop-daemon >/dev/null; then
76 start-stop-daemon --stop --quiet --oknodo --retry 30 \
77 --pidfile $pidfile --name "$name"
78 @@ -352,6 +395,9 @@ check_and_start() {
79 if use_systemctl; then
80 echo "${name} supervised by systemd but not running, will not restart."
82 + elif use_shepherd; then
83 + echo "${name} supervised by shepherd but not running, will not restart."