mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
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-configuration>)[shepherd]: Default to SHEPHERD-0.9. * gnu/system.scm (hurd-default-essential-services): Use SHEPHERD-0.8.
This commit is contained in:
parent
938448bf40
commit
400c9ed3d7
2 changed files with 35 additions and 25 deletions
|
@ -26,6 +26,7 @@ (define-module (gnu services shepherd)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:use-module (guix store)
|
#:use-module (guix store)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
|
#:use-module (guix packages)
|
||||||
#:use-module (guix derivations) ;imported-modules, etc.
|
#:use-module (guix derivations) ;imported-modules, etc.
|
||||||
#:use-module (guix utils)
|
#:use-module (guix utils)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
|
@ -88,7 +89,7 @@ (define-record-type* <shepherd-configuration>
|
||||||
shepherd-configuration make-shepherd-configuration
|
shepherd-configuration make-shepherd-configuration
|
||||||
shepherd-configuration?
|
shepherd-configuration?
|
||||||
(shepherd shepherd-configuration-shepherd
|
(shepherd shepherd-configuration-shepherd
|
||||||
(default shepherd)) ; file-like
|
(default shepherd-0.9)) ; file-like
|
||||||
(services shepherd-configuration-services
|
(services shepherd-configuration-services
|
||||||
(default '()))) ; list of <shepherd-service>
|
(default '()))) ; list of <shepherd-service>
|
||||||
|
|
||||||
|
@ -304,8 +305,14 @@ (define (shepherd-service-file service)
|
||||||
(define (scm->go file shepherd)
|
(define (scm->go file shepherd)
|
||||||
"Compile FILE, which contains code to be loaded by shepherd's config file,
|
"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."
|
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)
|
(let-system (system target)
|
||||||
(with-extensions (list shepherd)
|
(with-extensions shepherd&co
|
||||||
(computed-file (string-append (basename (scheme-file-name file) ".scm")
|
(computed-file (string-append (basename (scheme-file-name file) ".scm")
|
||||||
".go")
|
".go")
|
||||||
#~(begin
|
#~(begin
|
||||||
|
@ -359,29 +366,29 @@ (define config
|
||||||
(map load-compiled '#$(map scm->go files))))))
|
(map load-compiled '#$(map scm->go files))))))
|
||||||
|
|
||||||
(format #t "starting services...~%")
|
(format #t "starting services...~%")
|
||||||
(for-each (lambda (service)
|
(let ((services-to-start
|
||||||
;; In the Shepherd 0.3 the 'start' method can raise
|
'#$(append-map shepherd-service-provision
|
||||||
;; '&action-runtime-error' if it fails, so protect
|
(filter shepherd-service-auto-start?
|
||||||
;; against it. (XXX: 'action-runtime-error?' is not
|
services))))
|
||||||
;; exported is 0.3, hence 'service-error?'.)
|
(if (defined? 'start-in-the-background)
|
||||||
(guard (c ((service-error? c)
|
(start-in-the-background services-to-start)
|
||||||
(format (current-error-port)
|
(for-each (lambda (service) ;pre-0.9.0 compatibility
|
||||||
"failed to start service '~a'~%"
|
(guard (c ((service-error? c)
|
||||||
service)))
|
(format (current-error-port)
|
||||||
(start service)))
|
"failed to start service '~a'~%"
|
||||||
'#$(append-map shepherd-service-provision
|
service)))
|
||||||
(filter shepherd-service-auto-start?
|
(start service)))
|
||||||
services)))
|
services-to-start))
|
||||||
|
|
||||||
;; Hang up stdin. At this point, we assume that 'start' methods
|
;; Hang up stdin. At this point, we assume that 'start' methods
|
||||||
;; that required user interaction on the console (e.g.,
|
;; that required user interaction on the console (e.g.,
|
||||||
;; 'cryptsetup open' invocations, post-fsck emergency REPL) have
|
;; 'cryptsetup open' invocations, post-fsck emergency REPL) have
|
||||||
;; completed. User interaction becomes impossible after this
|
;; completed. User interaction becomes impossible after this
|
||||||
;; call; this avoids situations where services wrongfully lead
|
;; call; this avoids situations where services wrongfully lead
|
||||||
;; PID 1 to read from stdin (the console), which users may not
|
;; PID 1 to read from stdin (the console), which users may not
|
||||||
;; have access to (see <https://bugs.gnu.org/23697>).
|
;; have access to (see <https://bugs.gnu.org/23697>).
|
||||||
(redirect-port (open-input-file "/dev/null")
|
(redirect-port (open-input-file "/dev/null")
|
||||||
(current-input-port))))
|
(current-input-port)))))
|
||||||
|
|
||||||
(scheme-file "shepherd.conf" config)))
|
(scheme-file "shepherd.conf" config)))
|
||||||
|
|
||||||
|
|
|
@ -765,7 +765,10 @@ (define (hurd-default-essential-services os)
|
||||||
%boot-service
|
%boot-service
|
||||||
%hurd-startup-service
|
%hurd-startup-service
|
||||||
%activation-service
|
%activation-service
|
||||||
%shepherd-root-service
|
(service shepherd-root-service-type
|
||||||
|
(shepherd-configuration
|
||||||
|
(shepherd shepherd-0.8))) ;no Fibers
|
||||||
|
|
||||||
(service user-processes-service-type)
|
(service user-processes-service-type)
|
||||||
(account-service (append (operating-system-accounts os)
|
(account-service (append (operating-system-accounts os)
|
||||||
(operating-system-groups os))
|
(operating-system-groups os))
|
||||||
|
|
Loading…
Reference in a new issue