civodul pushed a commit to branch master
in repository shepherd.
commit eee779901379a729b50b8de225336c1533f7f69d
Author: Ludovic Courtès <[email protected]>
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))))))