[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/08: services: mcron: Validate jobs at build time.
From: |
guix-commits |
Subject: |
05/08: services: mcron: Validate jobs at build time. |
Date: |
Tue, 25 Aug 2020 18:52:54 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 949672c923b6a3953471c446e0b19f30be335572
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Aug 25 21:31:37 2020 +0200
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.
---
gnu/services/mcron.scm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index d9627c6..045d6e2 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -57,8 +57,26 @@
(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 @@ files."
(($ <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))
- branch master updated (e45d7f3 -> 253fcfe), guix-commits, 2020/08/25
- 02/08: gnu: hdf5: Distinguish the default hdf5 version., guix-commits, 2020/08/25
- 01/08: lint: Use 'with-error-handling'., guix-commits, 2020/08/25
- 04/08: gnu: hdf5: Use 'package/inherit' for variants., guix-commits, 2020/08/25
- 06/08: gnu: hdf5-parallel-openmpi: Update to 1.10.6., guix-commits, 2020/08/25
- 07/08: gnu: netcdf-parallel-openmpi: Allow MPI tests to pass., guix-commits, 2020/08/25
- 05/08: services: mcron: Validate jobs at build time.,
guix-commits <=
- 03/08: .dir-locals.el: Add indentation rule for 'package/inherit'., guix-commits, 2020/08/25
- 08/08: gnu: octave: Remove unneeded 'source' field., guix-commits, 2020/08/25