Welcome to little lamb

Code » anopa » commit b693add

status: Add mention "To be restarted"

author Olivier Brunel
2015-11-21 13:38:56 UTC
committer Olivier Brunel
2015-11-21 13:38:56 UTC
parent d29e2cb88c962afdb6c526098e9376ad610a08a3

status: Add mention "To be restarted"

For down services that s6-supervise shall be restarting soon, after finihs is
done and/or the 1sec delay.

Useful to see when e.g. a service keeps failing to start/be restarted.

doc/aa-status.pod +9 -3
src/anopa/aa-status.c +19 -0

diff --git a/doc/aa-status.pod b/doc/aa-status.pod
index 889c460..5526baa 100644
--- a/doc/aa-status.pod
+++ b/doc/aa-status.pod
@@ -246,8 +246,14 @@ though in list mode only the later in shown.
 The script I<run> isn't running anymore. Its exitcode or which signal killed it
 will be specified.
 
-I<Down & Ready> means the the I<finish> script (if any) also ended its execution
-(or was killed by B<s6-supervise>). Both times for down ('d') and end-of-finish
-('D') are shown, though in list mode (option B<--list>) only the later in shown.
+It can be followed by "To be restarted" when the service is expected to be
+restarted soon by its supervisor, e.g. the service just went down or its finish
+script is running, but within a few seconds its B<s6-supervise> shall be
+starting the run script again.
+
+I<Down & Ready> means that the I<finish> script (if any) also ended its
+execution (or was killed by B<s6-supervise>). Both times for down ('d') and
+end-of-finish ('D') are shown, though in list mode (option B<--list>) only the
+later in shown.
 
 =back
diff --git a/src/anopa/aa-status.c b/src/anopa/aa-status.c
index 46565ff..5539bdc 100644
--- a/src/anopa/aa-status.c
+++ b/src/anopa/aa-status.c
@@ -424,7 +424,26 @@ status_service (struct serv *serv, struct config *cfg)
             aa_is_noflush (AA_OUT, ANSI_HIGHLIGHT_OFF);
             put_s (" (");
             put_wstat (serv->st6.wstat, max, 0);
+            if (serv->st6.flagwant && serv->st6.flagwantup)
+            {
+                put_s ("; ");
+                aa_is_noflush (AA_OUT, ANSI_HIGHLIGHT_BLUE_ON);
+                put_s ("To be restarted");
+                aa_is_noflush (AA_OUT, ANSI_HIGHLIGHT_OFF);
+            }
             put_s (")");
+
+            /* if not in list mode, and it'll be restarted, let's show the mode
+             * as well then, for consistency/to be clearer.
+             * (We don't usually show it since it has no meaning when down,
+             * given that one cannot start a service w/out specifying the mode
+             * to be set (-u for up, -o for once))
+             */
+            if (cfg->mode != MODE_LIST && serv->st6.flagwant && serv->st6.flagwantup)
+            {
+                aa_bs_noflush (AA_OUT, "\nMode:    ");
+                put_s ("Automatic restart (want up)");
+            }
         }
     }
     else