diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-04-28 16:24:46 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-04-28 16:24:46 +0200 |
commit | 284fa7264963acc5d114ef5d54c347126b1654ba (patch) | |
tree | 3e5360fcc81b6d0dce76a65aca60cf8528f2931f /gnu/services/shepherd.scm | |
parent | 12c9da35389dfba86ae0d863132a6b2c4374205a (diff) | |
parent | 882cacc1bb5be0df334dd7ce55b385a3a1678728 (diff) | |
download | guix-patches-284fa7264963acc5d114ef5d54c347126b1654ba.tar guix-patches-284fa7264963acc5d114ef5d54c347126b1654ba.tar.gz |
Merge branch 'master' into staging
Diffstat (limited to 'gnu/services/shepherd.scm')
-rw-r--r-- | gnu/services/shepherd.scm | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index b44dbf9d9f..4fd4b2a497 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2013-2016, 2018-2022 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au> ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> @@ -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 <shepherd-service> @@ -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 <https://bugs.gnu.org/23697>). - (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 <https://bugs.gnu.org/23697>). + (redirect-port (open-input-file "/dev/null") + (current-input-port))))) (scheme-file "shepherd.conf" config))) @@ -463,8 +470,13 @@ need to be restarted to complete their upgrade." (filter running? target)) (define to-unload - ;; Unload services that are no longer required. - (remove essential? (filter obsolete? live))) + ;; Unload services that are no longer required. Essential services must + ;; be kept and transient services such as inetd child services should be + ;; kept as well--they'll vanish eventually. + (remove (lambda (live) + (or (essential? live) + (live-service-transient? live))) + (filter obsolete? live))) (values to-unload to-restart)) |