aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-02-05 11:39:27 +0100
committerLudovic Courtès <ludo@gnu.org>2016-02-05 14:01:46 +0100
commit1d6b7d584736ff0ad9e852a39c7c151e10713580 (patch)
treeb80702c38f8d07b9232fb0e3ee916fdfcf4f0a7b /guix/scripts
parent6b55ee88890c114f9829029c7d0c0c3f03bcda03 (diff)
downloadgnu-guix-1d6b7d584736ff0ad9e852a39c7c151e10713580.tar
gnu-guix-1d6b7d584736ff0ad9e852a39c7c151e10713580.tar.gz
guix system: Simply warn if we cannot talk to the shepherd.
Before that 'open-connection' would return #f, and thus 'current-services' would return a single #f value when its continuation expects two. Reported by calher on #guix. * gnu/services/herd.scm (open-connection): Rethrow system-error exceptions. (with-shepherd): Expect CONNECTION to always be true; remove useless 'dynamic-wind'. * guix/scripts/system.scm (warn-on-system-error): New macro. (upgrade-shepherd-services): Wrap body in 'warn-on-system-error'.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/system.scm84
1 files changed, 48 insertions, 36 deletions
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index e13355d399..7279be0c43 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -211,6 +211,16 @@ the ownership of '~a' may be incorrect!~%")
(lambda ()
(environ env)))))
+(define-syntax-rule (warn-on-system-error body ...)
+ (catch 'system-error
+ (lambda ()
+ body ...)
+ (lambda (key proc format-string format-args errno . rest)
+ (warning (_ "while talking to shepherd: ~a~%")
+ (apply format #f format-string format-args))
+ (with-monad %store-monad
+ (return #f)))))
+
(define (upgrade-shepherd-services os)
"Upgrade the Shepherd (PID 1) by unloading obsolete services and loading new
services specified in OS and not currently running.
@@ -230,42 +240,44 @@ bring the system down."
(map (compose first shepherd-service-provision)
new-services))
- (let-values (((running stopped) (current-services)))
- (define to-load
- ;; Only load services that are either new or currently stopped.
- (remove (lambda (service)
- (memq (first (shepherd-service-provision service))
- running))
- new-services))
- (define to-unload
- ;; Unload services that are (1) no longer required, or (2) are in
- ;; TO-LOAD.
- (remove essential?
- (append (remove (lambda (service)
- (memq service new-service-names))
- (append running stopped))
- (filter (lambda (service)
- (memq service stopped))
- (map shepherd-service-canonical-name
- to-load)))))
-
- (for-each (lambda (unload)
- (info (_ "unloading service '~a'...~%") unload)
- (unload-service unload))
- to-unload)
-
- (with-monad %store-monad
- (munless (null? to-load)
- (let ((to-load-names (map shepherd-service-canonical-name to-load))
- (to-start (filter shepherd-service-auto-start? to-load)))
- (info (_ "loading new services:~{ ~a~}...~%") to-load-names)
- (mlet %store-monad ((files (mapm %store-monad shepherd-service-file
- to-load)))
- (load-services (map derivation->output-path files))
-
- (for-each start-service
- (map shepherd-service-canonical-name to-start))
- (return #t)))))))
+ ;; Arrange to simply emit a warning if we cannot connect to the shepherd.
+ (warn-on-system-error
+ (let-values (((running stopped) (current-services)))
+ (define to-load
+ ;; Only load services that are either new or currently stopped.
+ (remove (lambda (service)
+ (memq (first (shepherd-service-provision service))
+ running))
+ new-services))
+ (define to-unload
+ ;; Unload services that are (1) no longer required, or (2) are in
+ ;; TO-LOAD.
+ (remove essential?
+ (append (remove (lambda (service)
+ (memq service new-service-names))
+ (append running stopped))
+ (filter (lambda (service)
+ (memq service stopped))
+ (map shepherd-service-canonical-name
+ to-load)))))
+
+ (for-each (lambda (unload)
+ (info (_ "unloading service '~a'...~%") unload)
+ (unload-service unload))
+ to-unload)
+
+ (with-monad %store-monad
+ (munless (null? to-load)
+ (let ((to-load-names (map shepherd-service-canonical-name to-load))
+ (to-start (filter shepherd-service-auto-start? to-load)))
+ (info (_ "loading new services:~{ ~a~}...~%") to-load-names)
+ (mlet %store-monad ((files (mapm %store-monad shepherd-service-file
+ to-load)))
+ (load-services (map derivation->output-path files))
+
+ (for-each start-service
+ (map shepherd-service-canonical-name to-start))
+ (return #t))))))))
(define* (switch-to-system os
#:optional (profile %system-profile))