[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 07/13: service: 'stop-service' returns the list of stopped se
From: |
Ludovic Courtès |
Subject: |
[shepherd] 07/13: service: 'stop-service' returns the list of stopped services, not names. |
Date: |
Sun, 16 Apr 2023 17:38:36 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit eee779901379a729b50b8de225336c1533f7f69d
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Apr 12 22:00:44 2023 +0200
service: 'stop-service' returns the list of stopped services, not names.
* modules/shepherd/service.scm (stop-service): Return the list of
stopped services rather than the list of canonical names.
(perform-service-action): Adjust accordingly in 'restart' case.
(stop): Call 'service-canonical-name' on the result.
* modules/shepherd.scm (process-command): Likewise.
* doc/shepherd.texi (Methods of services): Update accordingly.
---
doc/shepherd.texi | 3 +--
modules/shepherd.scm | 3 ++-
modules/shepherd/service.scm | 15 ++++++---------
3 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 0368d35..fe3441e 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -741,8 +741,7 @@ Start @var{service} and its dependencies, passing
@var{args} to its
@defun stop-service @var{service} . @var{args}
Stop @var{service} and any service that depends on it. Return the list of
-canonical names for all of the services that have been stopped (including
-transitive dependent services).
+services that have been stopped (including transitive dependent services).
If @var{service} is not running, print a warning and return its canonical name
in a list.
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index c2e478c..729332c 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -523,7 +523,8 @@ fork in the child process."
((stop)
(if (service-stopped? service)
'()
- (apply stop-service service args)))
+ (map service-canonical-name
+ (apply stop-service service args))))
;; XXX: This used to return a list of action results, on the
;; grounds that there could be several services called NAME.
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 00269e9..c24d404 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -797,8 +797,7 @@ NEW-SERVICE."
;; latter fails, continue anyway. Return `#f' if it could be stopped.
(define (stop-service service . args)
"Stop @var{service} and any service that depends on it. Return the list of
-canonical names for all of the services that have been stopped (including
-transitive dependent services).
+services that have been stopped (including transitive dependent services).
If @var{service} is not running, print a warning and return its canonical name
in a list."
@@ -806,9 +805,8 @@ in a list."
(begin
(local-output (l10n "Service ~a is not running.")
(service-canonical-name service))
- (list (service-canonical-name service)))
- (let ((name (service-canonical-name service))
- (stopped-dependents
+ (list service))
+ (let ((stopped-dependents
(fold-services (lambda (other acc)
(if (and (service-running? other)
(required-by? service other))
@@ -848,7 +846,7 @@ in a list."
(when replacement
(replace-service service replacement)))
- (cons name stopped-dependents))))
+ (cons service stopped-dependents))))
(define (perform-service-action service the-action . args)
"Perform @var{the-action} (a symbol such as @code{'restart} or
@code{'status})
@@ -862,8 +860,7 @@ the action."
((restart)
(lambda (running . args)
(let ((stopped-services (stop-service service)))
- (for-each (compose start-service lookup-service)
- stopped-services)
+ (for-each start-service stopped-services)
#t)))
((status)
;; Return the service itself. It is automatically converted to an sexp
@@ -2535,7 +2532,7 @@ Used by `start'."
(service
(if (service-stopped? service)
'()
- (apply stop service args)))))
+ (map service-canonical-name (apply stop service args))))))
- [shepherd] branch master updated (353a91b -> fbca4e2), Ludovic Courtès, 2023/04/16
- [shepherd] 08/13: shepherd: Factorize command message gathering., Ludovic Courtès, 2023/04/16
- [shepherd] 02/13: monitoring: Log registered service names., Ludovic Courtès, 2023/04/16
- [shepherd] 03/13: service: Turn 'doc' method into a procedure., Ludovic Courtès, 2023/04/16
- [shepherd] 04/13: service: Turn 'action' method into a procedure., Ludovic Courtès, 2023/04/16
- [shepherd] 11/13: service: Record time of last startup failures., Ludovic Courtès, 2023/04/16
- [shepherd] 09/13: comm: Capture the client command protocol version., Ludovic Courtès, 2023/04/16
- [shepherd] 07/13: service: 'stop-service' returns the list of stopped services, not names.,
Ludovic Courtès <=
- [shepherd] 12/13: tests: Remove reference to non-existent file., Ludovic Courtès, 2023/04/16
- [shepherd] 01/13: service: Use 'lookup-service' instead of 'lookup-services'., Ludovic Courtès, 2023/04/16
- [shepherd] 13/13: herd: Report startup failure., Ludovic Courtès, 2023/04/16
- [shepherd] 06/13: service: Turn 'stop' method into a procedure., Ludovic Courtès, 2023/04/16
- [shepherd] 05/13: service: Turn 'start' method into a procedure., Ludovic Courtès, 2023/04/16
- [shepherd] 10/13: Add missing 'l10n' calls., Ludovic Courtès, 2023/04/16