Ganeti uses an internal tool to start/stop daemons during init and upgrade. This patch makes the tool use native Shepherd facilities. diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in --- a/daemons/daemon-util.in +++ b/daemons/daemon-util.in @@ -184,6 +184,21 @@ use_systemctl() { return 1 } +# Checks if we should use the Shepherd to start/stop daemons +use_shepherd() { + # Is Shepherd running as PID 1? + ps --no-headers -p 1 -o cmd | grep -q shepherd || return 1 + + type -p herd >/dev/null || return 1 + + # Does Shepherd know about Ganeti at all? + if herd status | grep -q ganeti; then + return 0 + fi + + return 1 +} + # Prints path to PID file for a daemon. daemon_pidfile() { if [[ "$#" -lt 1 ]]; then @@ -261,6 +276,13 @@ check() { else return 1 fi + elif use_shepherd; then + activestate="$(herd status ${name})" + if echo $activestate | grep -q Running ; then + return 0 + else + return 1 + fi elif type -p start-stop-daemon >/dev/null; then start-stop-daemon --stop --signal 0 --quiet \ --pidfile $pidfile --name "$name" @@ -291,6 +313,20 @@ start() { return $? fi + if use_shepherd; then + if herd status "$name" | grep -q "disabled"; then + # The Shepherd will disable a service that has stopped, even if it exits + # gracefully. Thus, we must re-enable it in case of a master failover. + herd enable "${name}" + fi + # Note: unlike systemd, which happily starts a service and returns success + # even if the daemon immediately exits, the Shepherd actually waits for it + # to come up. Thus, ignore the exit status from 'herd start' in case of + # master daemons running on the wrong node, or ganeti-kvmd disabled, etc. + herd start "${name}" + return 0 + fi + # Read $_ARGS and $EXTRA__ARGS eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\"" @@ -336,6 +372,13 @@ stop() { if use_systemctl; then systemctl stop "${name}.service" + elif use_shepherd; then + if herd status | grep -q "$name"; then + herd stop "$name" + else + # Do not raise an error if the service has not been enabled. + return 0 + fi elif type -p start-stop-daemon >/dev/null; then start-stop-daemon --stop --quiet --oknodo --retry 30 \ --pidfile $pidfile --name "$name" @@ -352,6 +395,9 @@ check_and_start() { if use_systemctl; then echo "${name} supervised by systemd but not running, will not restart." return 1 + elif use_shepherd; then + echo "${name} supervised by shepherd but not running, will not restart." + return 1 fi start $name hor 2018-09-02compile-as-derivation: Adjust %load-compiled-path....* build-aux/compile-as-derivation.scm: Set not only %load-path but also %load-compiled-path. This can avoid problems where a stale .go is loaded. Ludovic Courtès 2018-06-09pull: Install the new Guix in a profile....* guix/scripts/pull.scm (%pull-version): New variable. (build-from-source): Pass #:pull-version to BUILD. (whole-package-for-legacy, derivation->manifest-entry): New procedure. (build-and-install): Rewrite in terms of 'build-and-use-profile'. * guix/scripts/system.scm (maybe-suggest-running-guix-pull)[latest]: Switch to "/current". * scripts/guix.in (augment-load-paths!): Remove use of ~/.config/guix/latest. * build-aux/compile-as-derivation.scm: Replace "/guix/latest/" with "/current/share/guile/site/X.Y" * guix/scripts.scm (warn-about-old-distro)[age]: Check "/current" instead of "/latest". * doc/guix.texi (Invoking guix pull): Document it. * doc/contributing.texi (Running Guix Before It Is Installed): Remove footnote about abusing ~/.config/guix/latest. Ludovic Courtès 2018-06-09self: Produce a complete package with the 'guix' command....* guix/self.scm (guix-command): New procedure. (compiled-guix): Add #:pull-version parameter. [command, package]: New variables. Honor PULL-VERSION. (guix-derivation): Add #:pull-version and pass it to 'compiled-guix'. * build-aux/build-self.scm (build-program): Add #:pull-version parameter. Pass it to 'guix-derivation'. (build): Add #:pull-version and pass it to 'build-program'. * build-aux/compile-as-derivation.scm: Pass #:pull-version to BUILD. Ludovic Courtès 2018-04-08build: Add 'as-derivation' target....* build-aux/compile-as-derivation.scm: New file. * Makefile.am (as-derivation): New target. (EXTRA_DIST): Add compile-as-derivation.scm. Ludovic Courtès