[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/05: shepherd: 'start' action returns service sexp on succe
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/05: shepherd: 'start' action returns service sexp on success. |
Date: |
Sun, 7 May 2023 17:18:02 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit fdd71a8bc936b2b8ac4548062398f9263142e973
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun May 7 22:53:30 2023 +0200
shepherd: 'start' action returns service sexp on success.
This behavior was inadvertently changed in
0fc51b65862f1386877340550c5c0309f9af13d9.
* modules/shepherd.scm (process-command): For 'start', return SERVICE
when 'start-service' succeeds.
* tests/status-sexp.sh: Add test.
---
modules/shepherd.scm | 4 +++-
tests/status-sexp.sh | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 8e47679..ad74089 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -529,12 +529,14 @@ while evaluating @var{command}."
(define result
(case the-action
((start)
+ ;; Return #f or SERVICE: clients expect the service sexp.
(if (eq? 'running (service-status service))
(begin
(local-output (l10n "Service ~a is already running.")
(service-canonical-name service))
service)
- (apply start-service service args)))
+ (and (apply start-service service args)
+ service)))
((stop)
(if (service-stopped? service)
'()
diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh
index 34b062c..8218406 100644
--- a/tests/status-sexp.sh
+++ b/tests/status-sexp.sh
@@ -128,6 +128,33 @@ $define_reset_timestamps
(one-shot? #f) (transient? #f)))))))
"
+# The 'start' command should return the service sexp on success.
+"$GUILE" -c "
+(use-modules (shepherd comm) (srfi srfi-1) (ice-9 match))
+
+$define_reset_timestamps
+
+(define (start name)
+ ;; Start service NAME.
+ (let ((sock (open-connection \"$socket\")))
+ (write-command (shepherd-command 'start name) sock)
+ (read sock)))
+
+(exit
+ (match (start 'bar)
+ (('reply _ ('result service) ('error #f) ('messages (_)))
+ (equal? (reset-timestamps service)
+ '(service (version 0)
+ (provides (bar)) (requires (foo))
+ (respawn? #f) (docstring \"Bar!\")
+ (enabled? #t) (running up-and-running) (conflicts ())
+ (last-respawns ())
+ (status-changes ((running . 0) (starting . 0)))
+ (startup-failures ())
+ (status running)
+ (one-shot? #f) (transient? #f))))))
+"
+
# Make sure we get an 'error' sexp when querying a nonexistent service.
"$GUILE" -c "
(use-modules (shepherd comm) (ice-9 match))
- [shepherd] branch master updated (7c79df1 -> 0d2a781), Ludovic Courtès, 2023/05/07
- [shepherd] 02/05: shepherd: 'start' action returns service sexp on success.,
Ludovic Courtès <=
- [shepherd] 03/05: tests: Remove tabs from 'status-sexp.sh'., Ludovic Courtès, 2023/05/07
- [shepherd] 05/05: build: Bump to version 0.10.0rc2., Ludovic Courtès, 2023/05/07
- [shepherd] 01/05: service: 'service->sexp' always emits 'one-shot?' and 'transient?'., Ludovic Courtès, 2023/05/07
- [shepherd] 04/05: nls: Update de, ro, and uk translations., Ludovic Courtès, 2023/05/07