[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.
- [shepherd] branch master updated (fbca4e2 -> 3ee3fad), Ludovic Courtès, 2023/04/19
- [shepherd] 03/07: herd: 'herd status' distinguishes services that failed to start.,
Ludovic Courtès <=
- [shepherd] 02/07: Switch from SRFI-11 to SRFI-71., Ludovic Courtès, 2023/04/19
- [shepherd] 06/07: support: Add colors to 'report-error'., Ludovic Courtès, 2023/04/19
- [shepherd] 05/07: support: 'verify-dir' reports errors with 'report-error'., Ludovic Courtès, 2023/04/19
- [shepherd] 04/07: Add (shepherd colors)., Ludovic Courtès, 2023/04/19
- [shepherd] 07/07: herd: Make 'status' output more colorful., Ludovic Courtès, 2023/04/19
- [shepherd] 01/07: .guix-channel: Add primary URL., Ludovic Courtès, 2023/04/19