[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 03/03: service: Do not attempt to restart transient services.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 03/03: service: Do not attempt to restart transient services. |
Date: |
Fri, 26 May 2023 09:22:53 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit 8ae2780ca22f63d10e0e7e3fa75c5e864e0fad1a
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri May 26 15:07:09 2023 +0200
service: Do not attempt to restart transient services.
* modules/shepherd/service.scm (perform-service-action): In 'restart',
do not restart transient services.
* tests/transient.sh: Test it.
* NEWS: Update.
---
NEWS | 6 ++++++
modules/shepherd/service.scm | 3 ++-
tests/transient.sh | 8 ++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 516244a..54df05c 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,12 @@ service (typically failing to start) while the original
service would still be
running “in the shadows” (responding to SIGCHLD or to incoming connections,
and so on).
+** ‘herd restart SERVICE’ does not restart transient services
+
+In 0.10.0, ‘herd restart’ could end up attempt to restart transient services,
+which is bound to fail and could even lead to a deadlock since the service has
+been terminated.
+
* Changes in 0.10.0
** Distinguish ‘starting’ and ‘stopping’ intermediate service statuses
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index f8849d5..63e7155 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -941,7 +941,8 @@ the action."
((restart)
(lambda (running . args)
(let ((stopped-services (stop-service service)))
- (for-each start-service stopped-services)
+ (for-each start-service
+ (remove transient-service? stopped-services))
#t)))
((status)
;; Return the service itself. It is automatically converted to an sexp
diff --git a/tests/transient.sh b/tests/transient.sh
index f61bb46..3f70dac 100644
--- a/tests/transient.sh
+++ b/tests/transient.sh
@@ -63,3 +63,11 @@ kill $($herd status transient-test2 | grep Running | sed
-e's/^.* \([0-9]\+\).*$
$herd status transient-test2 && false
test $($herd status | grep transient-test | wc -l) -eq 0
+
+# Ensure that restarting a transient service is impossible.
+$herd load root "$conf"
+$herd start transient-test1
+$herd restart transient-test1
+$herd status transient-test1 && false
+
+$herd unload root transient-test2