guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 03/05: herd: Interpret 'start' failures as an error.


From: Ludovic Courtès
Subject: [shepherd] 03/05: herd: Interpret 'start' failures as an error.
Date: Wed, 20 Jan 2016 21:16:53 +0000

civodul pushed a commit to branch master
in repository shepherd.

commit 6aff23823c99ce8a200d279a86d5eba2efe3ea88
Author: Ludovic Courtès <address@hidden>
Date:   Wed Jan 20 21:36:27 2016 +0100

    herd: Interpret 'start' failures as an error.
    
    * modules/shepherd/service.scm (launch-service): Return #f on failure.
    Remove 'local-output' call.
    * modules/herd.scm (run-command): Add case to interpret the result of
    'start'.
    * tests/basic.sh: Test exit code with disable/start/enable.
---
 modules/herd.scm             |    6 ++++++
 modules/shepherd/service.scm |    6 +++---
 tests/basic.sh               |    6 ++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/modules/herd.scm b/modules/herd.scm
index 9b4b272..7170e47 100644
--- a/modules/herd.scm
+++ b/modules/herd.scm
@@ -130,6 +130,12 @@ the daemon via SOCKET-FILE."
            ;; We get a list of statuses, in case several services have the
            ;; same name.
            (for-each display-service-status result))
+          (('start _)
+           (unless result
+             (format (current-error-port)
+                     (l10n "Failed to start service ~a~%")
+                     service)
+             (exit 1)))
           (_
            ;; For other commands, we don't do any interpretation.
            #t)))
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 212d25d..1a5acc6 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -473,9 +473,9 @@ clients."
 
 
 
-;; Try to start (with PROC) a service providing NAME.  Used by `start'
-;; and `enforce'.
 (define (launch-service name proc args)
+  "Try to start (with PROC) a service providing NAME; return #f on failure.
+Used by `start' and `enforce'."
   (match (lookup-services name)
     (()
      (raise (condition (&missing-service-error (name name)))))
@@ -492,7 +492,7 @@ clients."
            (if (and unknown
                     (defines-action? unknown 'start))
                (apply action unknown 'start name args)
-               (local-output "Providing ~a impossible." name)))))))
+               #f))))))
 
 ;; Starting by name.
 (define-method (start (obj <symbol>) . args)
diff --git a/tests/basic.sh b/tests/basic.sh
index f55ee2b..e62e8dc 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -79,6 +79,12 @@ $herd stop test
 
 $herd status test | grep stopped
 
+# Disable a service and make sure it cannot be started.
+$herd disable test-2
+if $herd start test-2
+then false; else true; fi
+
+$herd enable test-2
 $herd start test-2
 
 $herd status test-2 | grep started



reply via email to

[Prev in Thread] Current Thread [Next in Thread]