Welcome to little lamb

Code » anopa » commit 458548c

stop: Fix unable to stop service that keeps crashing

author Olivier Brunel
2015-11-21 14:36:38 UTC
committer Olivier Brunel
2015-11-21 14:36:38 UTC
parent b693add5f64bbff04201c60508e94947e32a842d

stop: Fix unable to stop service that keeps crashing

That is, when a service keeps crashing/stopping, and being restarted by its
supervise, we would see it as down and therefore not (allow to) stop it.

Now consider "to be restarted" to be up when stopping, to solve the issue. The
command will be sent to supervise (and the down file created), but we won't wait
for a 'd' event and announce it as "Not up".

src/libanopa/service.c +8 -0

diff --git a/src/libanopa/service.c b/src/libanopa/service.c
index 1c1d940..68785b0 100644
--- a/src/libanopa/service.c
+++ b/src/libanopa/service.c
@@ -250,6 +250,14 @@ aa_ensure_service_loaded (int si, aa_mode mode, int no_wants, aa_autoload_cb al_
                 is_up = st6.pid && !st6.flagfinishing;
                 if (is_up && aa_service (si)->gets_ready && st6.flagready)
                     is_up = 2;
+                else if ((mode & (AA_MODE_STOP | AA_MODE_STOP_ALL))
+                            && !is_up && st6.flagwant && st6.flagwantup)
+                    /* it is down, but to be restarted soon by s6-supervise; so
+                     * for our intent & purposes, it shall be considered up, so
+                     * that we stop the restart and place the down file.
+                     * (When starting, it's ok to send the up command, so we
+                     * should still consider it down then.) */
+                    is_up = 1;
             }
             else if (errno != ENOENT)
             {