mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
services: mcron: Validate jobs at build time.
That way, run-time errors in the job specs are caught at build time. * gnu/services/mcron.scm (job-file): Remove. (job-files): New procedure. (mcron-shepherd-services): Adjust accordingly.
This commit is contained in:
parent
4788e55420
commit
949672c923
1 changed files with 21 additions and 3 deletions
|
@ -57,8 +57,26 @@ (define-record-type* <mcron-configuration> mcron-configuration
|
|||
(jobs mcron-configuration-jobs ;list of <mcron-job>
|
||||
(default '())))
|
||||
|
||||
(define (job-file job)
|
||||
(scheme-file "mcron-job" job))
|
||||
(define (job-files mcron jobs)
|
||||
"Return a list of file-like object for JOBS, a list of gexps."
|
||||
(define (validated-file job)
|
||||
;; This procedure behaves like 'scheme-file' but it runs 'mcron
|
||||
;; --schedule' to detect any error in JOB.
|
||||
(computed-file "mcron-job"
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
|
||||
(call-with-output-file "job"
|
||||
(lambda (port)
|
||||
(write '#$job port)))
|
||||
|
||||
(invoke #+(file-append mcron "/bin/mcron")
|
||||
"--schedule=20" "job")
|
||||
(copy-file "job" #$output)))
|
||||
#:options '(#:env-vars (("COLUMNS" . "150")))))
|
||||
|
||||
(map validated-file jobs))
|
||||
|
||||
(define (shepherd-schedule-action mcron files)
|
||||
"Return a Shepherd action that runs MCRON with '--schedule' for the given
|
||||
|
@ -101,7 +119,7 @@ (define mcron-shepherd-services
|
|||
(($ <mcron-configuration> mcron ()) ;nothing to do!
|
||||
'())
|
||||
(($ <mcron-configuration> mcron jobs)
|
||||
(let ((files (map job-file jobs)))
|
||||
(let ((files (job-files mcron jobs)))
|
||||
(list (shepherd-service
|
||||
(provision '(mcron))
|
||||
(requirement '(user-processes))
|
||||
|
|
Loading…
Reference in a new issue