guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 05/07: herd: Display the last respawn time.


From: Ludovic Courtès
Subject: [shepherd] 05/07: herd: Display the last respawn time.
Date: Wed, 23 Mar 2016 21:41:04 +0000

civodul pushed a commit to branch master
in repository shepherd.

commit 78ed650bce01cca67eeca51da09c393c37666229
Author: Ludovic Courtès <address@hidden>
Date:   Wed Mar 23 22:01:34 2016 +0100

    herd: Display the last respawn time.
    
    Suggested by Danny Milosavljevic <address@hidden>.
    
    * modules/shepherd/scripts/herd.scm (display-service-status): Display
    'last-respawns'.
    * tests/respawn-throttling.sh: Test it.
---
 modules/shepherd/scripts/herd.scm |   11 +++++++++--
 tests/respawn-throttling.sh       |    2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/shepherd/scripts/herd.scm 
b/modules/shepherd/scripts/herd.scm
index e87fd03..0ad52b2 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -26,6 +26,7 @@
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-19)
   #:export (main))
 
 
@@ -66,7 +67,7 @@ of pairs."
   (match service
     (('service ('version 0 _ ...) properties ...)
      (alist-let* properties (provides requires running respawn? enabled?
-                             conflicts)
+                             conflicts last-respawns)
        (format #t (l10n "Status of ~a:~%") (first provides))
        (if running
            (begin
@@ -81,7 +82,13 @@ of pairs."
        (format #t (l10n "  Conflicts with ~a.~%") conflicts)
        (if respawn?
            (format #t (l10n "  Will be respawned.~%"))
-           (format #t (l10n "  Will not be respawned.~%")))))))
+           (format #t (l10n "  Will not be respawned.~%")))
+       (match last-respawns
+         ((time _ ...)
+          (format #t (l10n "  Last respawned on ~a.~%")
+                  (date->string
+                   (time-utc->date (make-time time-utc 0 time)))))
+         (_ #t))))))
 
 (define (run-command socket-file action service args)
   "Perform ACTION with ARGS on SERVICE, and display the result.  Connect to
diff --git a/tests/respawn-throttling.sh b/tests/respawn-throttling.sh
index 13ada5d..3a98944 100644
--- a/tests/respawn-throttling.sh
+++ b/tests/respawn-throttling.sh
@@ -74,4 +74,6 @@ $herd status keeps-respawning | grep disabled
 if $herd start keeps-respawning
 then false; else true; fi
 
+$herd status keeps-respawning | grep -i "last respawned"
+
 grep -i "respawning too fast" "$log"



reply via email to

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