aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2024-05-25 16:52:29 +0200
committerLudovic Courtès <ludo@gnu.org>2024-05-25 16:52:29 +0200
commitcca25a67693bb68a1884a081b415a43fad1e8641 (patch)
treefc7575ad5a33b3c7d1f61f670dfe134913df7f28 /gnu
parent5a7cb59648d102168bd4ecd16f36b69e0f594be1 (diff)
downloadguix-cca25a67693bb68a1884a081b415a43fad1e8641.tar.gz
guix-cca25a67693bb68a1884a081b415a43fad1e8641.zip
services: shepherd: Failure to load a service does not prevent booting.
Fixes <https://issues.guix.gnu.org/71144>. Fixes a bug whereby, when loading a service file would fail, for instance due to an unbound variable, a REPL would be opened on the console, preventing the system from booting. This fixes that by isolating service load errors and making them non-fatal. * gnu/services/shepherd.scm (shepherd-configuration-file)[config]: Remove call to ‘call-with-error-handling’. Use ‘filter-map’ instead of ‘map’ to iterate over service files, and catch exceptions raised by ‘load-compiled’. Change-Id: Ie6e76ea514837f85386232f797bc77b2882b5c22
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services/shepherd.scm35
1 files changed, 20 insertions, 15 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 455e972535..ccc8e61a33 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -380,8 +380,7 @@ as shepherd package."
(scm->go (cute scm->go <> shepherd)))
(define config
#~(begin
- (use-modules (srfi srfi-34)
- (system repl error-handling))
+ (use-modules (srfi srfi-1))
(define (make-user-module)
;; Copied from (shepherd support), where it's private.
@@ -415,19 +414,25 @@ as shepherd package."
;; <https://bugs.gnu.org/40572>.
(default-pid-file-timeout 30)
- ;; Arrange to spawn a REPL if something goes wrong. This is better
- ;; than a kernel panic.
- (call-with-error-handling
- (lambda ()
- (register-services
- (parameterize ((current-warning-port
- (%make-void-port "w")))
- (map (lambda (file)
- (save-module-excursion
- (lambda ()
- (set-current-module (make-user-module))
- (load-compiled file))))
- '#$(map scm->go files))))))
+ ;; Load service files one by one; filter out those that could not be
+ ;; loaded--e.g., due to an unbound variable--such that an error in
+ ;; one service definition does not prevent the system from booting.
+ (register-services
+ (parameterize ((current-warning-port (%make-void-port "w")))
+ (filter-map (lambda (file)
+ (with-exception-handler
+ (lambda (exception)
+ (format #t "Exception caught \
+while loading '~a': ~s~%"
+ file exception)
+ #f)
+ (lambda ()
+ (save-module-excursion
+ (lambda ()
+ (set-current-module (make-user-module))
+ (load-compiled file))))
+ #:unwind? #t))
+ '#$(map scm->go files))))
(format #t "starting services...~%")
(let ((services-to-start