Welcome to little lamb

Code » anopa » commit d29e2cb

status: Add "mode" (want up/down in s6 speak)

author Olivier Brunel
2015-11-21 13:22:11 UTC
committer Olivier Brunel
2015-11-21 13:22:11 UTC
parent a943982d8b75ded99dcc2d7aad90b99ba17c7959

status: Add "mode" (want up/down in s6 speak)

I find the s6 terminology a bit unclear/confusing (possibly also because the
"want up" mention makes no sense, since one cannot start the service without
setting the mode), so we use "Mode" w/ "Automatic restart" or "Once" instead,
which seems better to me (the "want up/down" is still provided though).

In list mode, only show "Once" next to the PID when needed.

doc/aa-status.pod +8 -1
src/anopa/aa-status.c +17 -0

diff --git a/doc/aa-status.pod b/doc/aa-status.pod
index aba0268..889c460 100644
--- a/doc/aa-status.pod
+++ b/doc/aa-status.pod
@@ -228,9 +228,16 @@ This script I<start>/I<stop> succesfully ran (i.e. and returned 0).
 
 The script I<run> is currently running; Its PID will be specified.
 
+In list mode (option B<--list>), the word "Once" might appear next to the PID.
+This is done when the service is running in mode once, i.e. will not be
+automatically restarted when it goes down.
+
+In standard output (i.e. without option B<--list>), this information is shown
+under "Mode".
+
 I<Up & Ready> means that the service indicated readiness (or it was set via e.g.
 B<aa-setready>(1)). Both times for up ('u') and readiness ('U') are shown,
-though in list mode (option B<--list>) only the later in shown.
+though in list mode only the later in shown.
 
 =item B<Down> / B<Down & Ready>
 
diff --git a/src/anopa/aa-status.c b/src/anopa/aa-status.c
index b2749ee..46565ff 100644
--- a/src/anopa/aa-status.c
+++ b/src/anopa/aa-status.c
@@ -394,7 +394,24 @@ status_service (struct serv *serv, struct config *cfg)
             put_s (" (PID ");
             buf[uint_fmt (buf, serv->st6.pid)] = '\0';
             put_s (buf);
+            if (cfg->mode == MODE_LIST && !serv->st6.flagwant)
+            {
+                put_s ("; Once");
+            }
             put_s (")");
+
+            if (cfg->mode != MODE_LIST)
+            {
+                aa_bs_noflush (AA_OUT, "\nMode:    ");
+                if (serv->st6.flagwant)
+                {
+                    put_s ("Automatic restart (want up)");
+                }
+                else
+                {
+                    put_s ("Once (want down)");
+                }
+            }
         }
         else
         {