guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 03/07: herd: 'herd status' distinguishes services that failed


From: Ludovic Courtès
Subject: [shepherd] 03/07: herd: 'herd status' distinguishes services that failed to start.
Date: Wed, 19 Apr 2023 18:17:32 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 462cd1246f7703526b765d74d1932bf7882b88f2
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Apr 19 12:38:44 2023 +0200

    herd: 'herd status' distinguishes services that failed to start.
    
    * modules/shepherd/scripts/herd.scm (display-status-summary): Define
    'failing' and display them separately from stopped services.
    * tests/startup-failure.sh: Test it.
---
 modules/shepherd/scripts/herd.scm | 13 +++++++++++--
 tests/startup-failure.sh          |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/modules/shepherd/scripts/herd.scm 
b/modules/shepherd/scripts/herd.scm
index fe1ed66..30a163e 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -70,7 +70,13 @@ of pairs."
                                  ;; 'one-shot?' property; thus, do not assume
                                  ;; that it's available.
                                  (and=> (assoc-ref properties 'one-shot?) 
car)))
-                              stopped)))
+                              stopped))
+         (failing stopped
+                  (partition (match-lambda
+                               (('service ('version 0 _ ...) properties ...)
+                                (and=> (assoc-ref properties 'startup-failures)
+                                       (compose pair? car))))
+                             stopped)))
     (display-services (l10n "Started:\n") "+"
                       started)
     (display-services (l10n "Stopped:\n") "-"
@@ -80,7 +86,10 @@ of pairs."
     ;; services that are immediately marked as stopped once their 'start'
     ;; method has completed.
     (display-services (l10n "One-shot:\n") "*"
-                      one-shot)))
+                      one-shot)
+
+    (display-services (l10n "Failed to start:\n") "!"
+                      failing)))
 
 (define (display-detailed-status services)
   "Display the detailed status of SERVICES."
diff --git a/tests/startup-failure.sh b/tests/startup-failure.sh
index 9351ca8..80dd49a 100644
--- a/tests/startup-failure.sh
+++ b/tests/startup-failure.sh
@@ -48,11 +48,13 @@ while ! test -f "$pid"; do sleep 0.5 ; done
 if $herd start may-fail; then false; else true; fi
 $herd status may-fail | grep stopped
 $herd status may-fail | grep "Failed to start"
+$herd status | grep "Failed to start:"
 
 touch "$stamp"
 $herd start may-fail
 $herd status may-fail | grep started
 $herd status may-fail | grep -v "Failed to start"
+$herd status | grep -v "Failed to start:"
 
 # Once the service has been stopped gracefully, the "Failed to start" message
 # should not appear any longer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]