[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/03: service: When 'start' throws, mark the service as "sto
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/03: service: When 'start' throws, mark the service as "stopped". |
Date: |
Thu, 2 Mar 2023 17:00:20 -0500 (EST) |
civodul pushed a commit to branch master
in repository shepherd.
commit b5e0b8432ab6d8736197c5383898d59ba7782751
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Mar 2 22:52:06 2023 +0100
service: When 'start' throws, mark the service as "stopped".
Previously the service would be left indefinitely in 'starting' status
because there would never be a message on NOTIFICATION.
* modules/shepherd/service.scm (start): In 'catch' handler around
'start' call, add 'put-message' call before 'report-exception'.
* tests/basic.sh: Check that the status of 'broken' is stopped after
attempting to start it.
---
modules/shepherd/service.scm | 1 +
tests/basic.sh | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 2c2deb2..f8295d9 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -587,6 +587,7 @@ that could not be started."
(lambda ()
(apply (slot-ref obj 'start) args))
(lambda (key . args)
+ (put-message notification #f)
(report-exception 'start obj key
args)))))
(put-message notification running)
running))))))
diff --git a/tests/basic.sh b/tests/basic.sh
index 07e9767..de0a7d9 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -1,5 +1,5 @@
# GNU Shepherd --- Test basic communication capabilities.
-# Copyright © 2013-2014, 2016-2019, 2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2013-2014, 2016-2019, 2022-2023 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2014 Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
#
@@ -141,8 +141,9 @@ done
if $herd an-action-that-does-not-exist root
then false; else true; fi
-if $herd start broken
-then false; else true; fi
+# Check the behavior for a service whose 'start' method throws.
+! $herd start broken
+$herd status broken | grep "stopped"
# Wrong number of arguments for an action.
if $herd status root foo bar baz;