[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 08/08: service: 'stop-service' returns the list of stopped se
From: |
Ludovic Courtès |
Subject: |
[shepherd] 08/08: service: 'stop-service' returns the list of stopped services, not names. |
Date: |
Thu, 13 Apr 2023 05:43:12 -0400 (EDT) |
civodul pushed a commit to branch wip-goopsless
in repository shepherd.
commit 89853a314bfc573d0ebec2a921e24f976e341e6a
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 6c6b884..0a2dc06 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -796,8 +796,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."
@@ -805,9 +804,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))
@@ -847,7 +845,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})
@@ -861,8 +859,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
@@ -2526,7 +2523,7 @@ Used by `start'."
(service
(if (service-stopped? service)
'()
- (apply stop service args)))))
+ (map service-canonical-name (apply stop service args))))))
- [shepherd] branch wip-goopsless updated (a353fa5 -> 89853a3), Ludovic Courtès, 2023/04/13
- [shepherd] 07/08: squash! service: Use 'lookup-service' instead of 'lookup-services'., Ludovic Courtès, 2023/04/13
- [shepherd] 05/08: service: Turn 'start' method into a procedure., Ludovic Courtès, 2023/04/13
- [shepherd] 03/08: service: Turn 'action' method into a procedure., Ludovic Courtès, 2023/04/13
- [shepherd] 08/08: service: 'stop-service' returns the list of stopped services, not names.,
Ludovic Courtès <=
- [shepherd] 01/08: monitoring: Log registered service names., Ludovic Courtès, 2023/04/13
- [shepherd] 02/08: service: Turn 'doc' method into a procedure., Ludovic Courtès, 2023/04/13
- [shepherd] 04/08: squash! service: Use 'lookup-service' instead of 'lookup-services'., Ludovic Courtès, 2023/04/13
- [shepherd] 06/08: service: Turn 'stop' method into a procedure., Ludovic Courtès, 2023/04/13