From 400c9ed3d779308e56038305d40cd93acb496180 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 28 Mar 2022 14:01:10 +0200 Subject: services: shepherd: Default to version 0.9. * gnu/services/shepherd.scm (scm->go): Define 'shepherd&co' and pass it to 'with-extensions'. (shepherd-configuration-file): Call 'start-in-the-background' when it is defined. ()[shepherd]: Default to SHEPHERD-0.9. * gnu/system.scm (hurd-default-essential-services): Use SHEPHERD-0.8. --- gnu/services/shepherd.scm | 57 ++++++++++++++++++++++++++--------------------- gnu/system.scm | 5 ++++- 2 files changed, 36 insertions(+), 26 deletions(-) (limited to 'gnu') diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index b44dbf9d9f..5e8880cefe 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -26,6 +26,7 @@ #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix records) + #:use-module (guix packages) #:use-module (guix derivations) ;imported-modules, etc. #:use-module (guix utils) #:use-module (gnu services) @@ -88,7 +89,7 @@ shepherd-configuration make-shepherd-configuration shepherd-configuration? (shepherd shepherd-configuration-shepherd - (default shepherd)) ; file-like + (default shepherd-0.9)) ; file-like (services shepherd-configuration-services (default '()))) ; list of @@ -304,8 +305,14 @@ stored." (define (scm->go file shepherd) "Compile FILE, which contains code to be loaded by shepherd's config file, and return the resulting '.go' file. SHEPHERD is used as shepherd package." + (define shepherd&co + (cons shepherd + (match (lookup-package-input shepherd "guile-fibers") + (#f '()) + (fibers (list fibers))))) + (let-system (system target) - (with-extensions (list shepherd) + (with-extensions shepherd&co (computed-file (string-append (basename (scheme-file-name file) ".scm") ".go") #~(begin @@ -359,29 +366,29 @@ as shepherd package." (map load-compiled '#$(map scm->go files)))))) (format #t "starting services...~%") - (for-each (lambda (service) - ;; In the Shepherd 0.3 the 'start' method can raise - ;; '&action-runtime-error' if it fails, so protect - ;; against it. (XXX: 'action-runtime-error?' is not - ;; exported is 0.3, hence 'service-error?'.) - (guard (c ((service-error? c) - (format (current-error-port) - "failed to start service '~a'~%" - service))) - (start service))) - '#$(append-map shepherd-service-provision - (filter shepherd-service-auto-start? - services))) - - ;; Hang up stdin. At this point, we assume that 'start' methods - ;; that required user interaction on the console (e.g., - ;; 'cryptsetup open' invocations, post-fsck emergency REPL) have - ;; completed. User interaction becomes impossible after this - ;; call; this avoids situations where services wrongfully lead - ;; PID 1 to read from stdin (the console), which users may not - ;; have access to (see ). - (redirect-port (open-input-file "/dev/null") - (current-input-port)))) + (let ((services-to-start + '#$(append-map shepherd-service-provision + (filter shepherd-service-auto-start? + services)))) + (if (defined? 'start-in-the-background) + (start-in-the-background services-to-start) + (for-each (lambda (service) ;pre-0.9.0 compatibility + (guard (c ((service-error? c) + (format (current-error-port) + "failed to start service '~a'~%" + service))) + (start service))) + services-to-start)) + + ;; Hang up stdin. At this point, we assume that 'start' methods + ;; that required user interaction on the console (e.g., + ;; 'cryptsetup open' invocations, post-fsck emergency REPL) have + ;; completed. User interaction becomes impossible after this + ;; call; this avoids situations where services wrongfully lead + ;; PID 1 to read from stdin (the console), which users may not + ;; have access to (see ). + (redirect-port (open-input-file "/dev/null") + (current-input-port))))) (scheme-file "shepherd.conf" config))) diff --git a/gnu/system.scm b/gnu/system.scm index c8375680ee..c3810cbeeb 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -765,7 +765,10 @@ bookkeeping." %boot-service %hurd-startup-service %activation-service - %shepherd-root-service + (service shepherd-root-service-type + (shepherd-configuration + (shepherd shepherd-0.8))) ;no Fibers + (service user-processes-service-type) (account-service (append (operating-system-accounts os) (operating-system-groups os)) -- cgit v1.2.3