service: shepherd: All of the config file is in 'call-with-error-handling'.

* gnu/services/shepherd.scm (shepherd-configuration-file)[config]: Wrap
all the body in 'call-with-error-handling'.
This commit is contained in:
Ludovic Courtès 2016-02-05 13:23:09 +01:00
parent 081bd3bd29
commit 234ea8a71c
1 changed files with 20 additions and 19 deletions

View File

@ -237,29 +237,30 @@ stored."
(use-modules (srfi srfi-34) (use-modules (srfi srfi-34)
(system repl error-handling)) (system repl error-handling))
;; Arrange to spawn a REPL if loading one of FILES fails. This is ;; Arrange to spawn a REPL if something goes wrong. This is better
;; better than a kernel panic. ;; than a kernel panic.
(call-with-error-handling (call-with-error-handling
(lambda () (lambda ()
(apply register-services (map primitive-load '#$files)))) (apply register-services (map primitive-load '#$files))
;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around it. ;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around
(setenv "PATH" "/run/current-system/profile/bin") ;; it.
(setenv "PATH" "/run/current-system/profile/bin")
(format #t "starting services...~%") (format #t "starting services...~%")
(for-each (lambda (service) (for-each (lambda (service)
;; In the Shepherd 0.3 the 'start' method can raise ;; In the Shepherd 0.3 the 'start' method can raise
;; '&action-runtime-error' if it fails, so protect ;; '&action-runtime-error' if it fails, so protect
;; against it. (XXX: 'action-runtime-error?' is not ;; against it. (XXX: 'action-runtime-error?' is not
;; exported is 0.3, hence 'service-error?'.) ;; exported is 0.3, hence 'service-error?'.)
(guard (c ((service-error? c) (guard (c ((service-error? c)
(format (current-error-port) (format (current-error-port)
"failed to start service '~a'~%" "failed to start service '~a'~%"
service))) service)))
(start service))) (start service)))
'#$(append-map shepherd-service-provision '#$(append-map shepherd-service-provision
(filter shepherd-service-auto-start? (filter shepherd-service-auto-start?
services))))) services)))))))
(gexp->file "shepherd.conf" config))) (gexp->file "shepherd.conf" config)))