guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 01/03: service: Remove 'stop-delay?' and 'waiting-for-termina


From: Ludovic Courtès
Subject: [shepherd] 01/03: service: Remove 'stop-delay?' and 'waiting-for-termination?'.
Date: Sat, 12 Nov 2022 16:44:26 -0500 (EST)

civodul pushed a commit to branch wip-service-monitor
in repository shepherd.

commit 29a6a3747dbcafe52090c0c15631713a9fce982d
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed May 4 22:27:08 2022 +0200

    service: Remove 'stop-delay?' and 'waiting-for-termination?'.
    
    The 'stop-delay?' feature had weird semantics, was untested, and most
    likely unused.
    
    * modules/shepherd/service.scm (<service>)[stop-delay?]
    [waiting-for-termination?]: Remove.
    (stop): Remove code to handle 'stop-delay?'.
    (respawn-service): Remove code to handle 'waiting-for-termination?'.
    * doc/shepherd.texi (Slots of services): Adjust accordingly.
    * doc/examples/wolfgangj.scm: Likewise.
---
 doc/examples/wolfgangj.scm   |   2 +-
 doc/shepherd.texi            |  18 -------
 modules/shepherd/service.scm | 126 ++++++++++++++++++-------------------------
 3 files changed, 53 insertions(+), 93 deletions(-)

diff --git a/doc/examples/wolfgangj.scm b/doc/examples/wolfgangj.scm
index 5fae7c1..adb8ed2 100644
--- a/doc/examples/wolfgangj.scm
+++ b/doc/examples/wolfgangj.scm
@@ -60,7 +60,7 @@
       #:respawn? #t
       #:start (make-forkexec-constructor getty "38400"
                                          (cat "tty" (number->string num)))
-      #:stop-delay? #t)))
+      #:stop (make-kill-destructor))))
 
 ;; Number of terminals created by default.
 (define default-terms 3)
diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 96daac8..bec87e5 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -760,24 +760,6 @@ element contains the time when it was restarted, initially 
all 0,
 later a time in seconds since the Epoch.  The first element is the one
 that contains the oldest one, the last one the newest.
 
-@item
-@vindex stop-delay? (slot of <service>)
-@code{stop-delay?} being false causes the @code{stop} slot to be
-unused; instead, stopping the service will just cause the
-@code{waiting-for-termination?} slot be set to @code{#t}.
-
-@item
-@vindex waiting-for-termination? (slot of <service>)
-@code{waiting-for-termination?} cannot be initialized with a keyword
-and should not be used by others, it is only used internally for
-respawnable services when the @code{stop-delay?} slot contains a true
-value.  @code{waiting-for-termination?} contains @code{#t} if the
-service is still running, but the user requested that it be stopped,
-in which case if the service terminates the next time, the respawn
-handler will not start it again.
-
-otherwise @code{#f}.
-
 @item
 @vindex replacement (slot of <service>)
 @code{replacement} specifies a service to be used to replace this one
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index e851406..6f1d13d 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -268,14 +268,6 @@ Log abnormal termination reported by @var{status}."
   ;; also possible to enable or disable it manually.
   (enabled? #:init-value #t
            #:getter enabled?)
-  ;; Some services should not be directly stopped, but should not be
-  ;; respawned anymore instead.  This field indicates that we are in
-  ;; the phase after the stop but before the termination.
-  (waiting-for-termination? #:init-value #f)
-  ;; This causes the above to be used.  When this is `#t', there is no
-  ;; need for a destructor (i.e. no value in the `stop' slot).
-  (stop-delay? #:init-keyword #:stop-delay?
-              #:init-value #f)
   ;; The times of the last respawns, most recent first.
   (last-respawns #:init-form '())
   ;; A replacement for when this service is stopped.
@@ -462,56 +454,50 @@ is not already running, and will return SERVICE's 
canonical name in a list."
            (local-output (l10n "Service ~a is not running.")
                          (canonical-name service))
            (list (canonical-name service)))
-         (if (slot-ref service 'stop-delay?)
-             (begin
-               (slot-set! service 'waiting-for-termination? #t)
-               (local-output (l10n "Service ~a pending to be stopped.")
-                             (canonical-name service))
-               (list (canonical-name service)))
-             (let ((name (canonical-name service))
-                   (stopped-dependents (fold-services (lambda (other acc)
-                                                        (if (and (running? 
other)
-                                                                 (required-by? 
service other))
-                                                            (append (stop 
other) acc)
-                                                            acc))
-                                                      '())))
-               ;; Stop the service itself.
-               (catch #t
-                 (lambda ()
-                   (apply (slot-ref service 'stop)
-                          (service-running-value service)
-                          args))
-                 (lambda (key . args)
-                   ;; Special case: 'root' may quit.
-                   (and (eq? root-service service)
-                        (eq? key 'quit)
-                        (apply quit args))
-                   (caught-error key args)))
-
-               ;; SERVICE is no longer running.
-               (slot-set! service 'running #f)
-
-               ;; Reset the list of respawns.
-               (slot-set! service 'last-respawns '())
-
-               ;; Replace the service with its replacement, if it has one
-               (let ((replacement (slot-ref service 'replacement)))
-                 (when replacement
-                   (replace-service service replacement)))
-
-               ;; Status message.
-               (if (running? service)
-                   (local-output (l10n "Service ~a could not be stopped.")
-                                 name)
-                   (local-output (l10n "Service ~a has been stopped.")
-                                 name))
-
-               (when (transient? service)
-                 (hashq-remove! %services (canonical-name service))
-                 (local-output (l10n "Transient service ~a unregistered.")
-                               (canonical-name service)))
-
-               (cons name stopped-dependents)))))))
+         (let ((name (canonical-name service))
+               (stopped-dependents (fold-services (lambda (other acc)
+                                                    (if (and (running? other)
+                                                             (required-by? 
service other))
+                                                        (append (stop other) 
acc)
+                                                        acc))
+                                                  '())))
+           ;; Stop the service itself.
+           (catch #t
+             (lambda ()
+               (apply (slot-ref service 'stop)
+                      (service-running-value service)
+                      args))
+             (lambda (key . args)
+               ;; Special case: 'root' may quit.
+               (and (eq? root-service service)
+                    (eq? key 'quit)
+                    (apply quit args))
+               (caught-error key args)))
+
+           ;; SERVICE is no longer running.
+           (slot-set! service 'running #f)
+
+           ;; Reset the list of respawns.
+           (slot-set! service 'last-respawns '())
+
+           ;; Replace the service with its replacement, if it has one
+           (let ((replacement (slot-ref service 'replacement)))
+             (when replacement
+               (replace-service service replacement)))
+
+           ;; Status message.
+           (if (running? service)
+               (local-output (l10n "Service ~a could not be stopped.")
+                             name)
+               (local-output (l10n "Service ~a has been stopped.")
+                             name))
+
+           (when (transient? service)
+             (hashq-remove! %services (canonical-name service))
+             (local-output (l10n "Transient service ~a unregistered.")
+                           (canonical-name service)))
+
+           (cons name stopped-dependents))))))
 
 ;; Call action THE-ACTION with ARGS.
 (define-method (action (obj <service>) the-action . args)
@@ -1816,22 +1802,14 @@ then disable it."
            (not (respawn-limit-hit? (slot-ref serv 'last-respawns)
                                     (car respawn-limit)
                                     (cdr respawn-limit))))
-      (if (not (slot-ref serv 'waiting-for-termination?))
-          (begin
-            ;; Everything is okay, start it.
-            (local-output (l10n "Respawning ~a.")
-                          (canonical-name serv))
-            (slot-set! serv 'last-respawns
-                       (cons (current-time)
-                             (slot-ref serv 'last-respawns)))
-            (start serv))
-          ;; We have just been waiting for the
-          ;; termination.  The `running' slot has already
-          ;; been set to `#f' by `stop'.
-          (begin
-            (local-output (l10n "Service ~a terminated.")
-                          (canonical-name serv))
-            (slot-set! serv 'waiting-for-termination? #f)))
+      (begin
+        ;; Everything is okay, start it.
+        (local-output (l10n "Respawning ~a.")
+                      (canonical-name serv))
+        (slot-set! serv 'last-respawns
+                   (cons (current-time)
+                         (slot-ref serv 'last-respawns)))
+        (start serv))
       (begin
         (local-output (l10n "Service ~a has been disabled.")
                       (canonical-name serv))



reply via email to

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