me
/
guix
Archived
1
0
Fork 0

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
master
Ludovic Courtès 2024-05-25 16:52:29 +02:00
parent 5a7cb59648
commit cca25a6769
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 20 additions and 15 deletions

View File

@ -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