GNU bug report logs - #62169
[PATCH 0/3] services: mcron: Make log-file and date-format configurable.

Previous Next

Package: guix-patches;

Reported by: Bruno Victal <mirai <at> makinata.eu>

Date: Mon, 13 Mar 2023 19:20:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bruno Victal <mirai <at> makinata.eu>
To: 62169 <at> debbugs.gnu.org
Cc: Bruno Victal <mirai <at> makinata.eu>
Subject: [bug#62169] [PATCH 2/3] services: mcron: Use match-record.
Date: Mon, 13 Mar 2023 19:30:49 +0000
* gnu/services/mcron.scm (mcron-shepherd-services): Use match-record.
---
 gnu/services/mcron.scm | 68 ++++++++++++++++++++----------------------
 1 file changed, 33 insertions(+), 35 deletions(-)

diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 6ee333f253..9f3afecf62 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -143,41 +143,39 @@ (define (shepherd-schedule-action mcron files)
                (display line)
                (loop)))))))))
 
-(define mcron-shepherd-services
-  (match-lambda
-    (($ <mcron-configuration> mcron ()) ;nothing to do!
-     '())
-    (($ <mcron-configuration> mcron jobs log? log-format)
-     (let ((files (job-files mcron jobs)))
-       (list (shepherd-service
-              (provision '(mcron))
-              (requirement '(user-processes))
-              (modules `((srfi srfi-1)
-                         (srfi srfi-26)
-                         (ice-9 popen)  ;for the 'schedule' action
-                         (ice-9 rdelim)
-                         (ice-9 match)
-                         ,@%default-modules))
-              (start #~(make-forkexec-constructor
-                        (list (string-append #$mcron "/bin/mcron")
-                              #$@(if log?
-                                     #~("--log" "--log-format" #$log-format)
-                                     #~())
-                              #$@files)
-
-                        ;; Disable auto-compilation of the job files and set a
-                        ;; sane value for 'PATH'.
-                        #:environment-variables
-                        (cons* "GUILE_AUTO_COMPILE=0"
-                               "PATH=/run/current-system/profile/bin"
-                               (remove (cut string-prefix? "PATH=" <>)
-                                       (environ)))
-
-                        #:log-file "/var/log/mcron.log"))
-              (stop #~(make-kill-destructor))
-
-              (actions
-               (list (shepherd-schedule-action mcron files)))))))))
+(define (mcron-shepherd-services config)
+  (match-record config <mcron-configuration> (mcron jobs log? log-format)
+    (if (eq? jobs '())
+        '()  ; nothing to do
+        (let ((files (job-files mcron jobs)))
+          (list (shepherd-service
+                 (provision '(mcron))
+                 (requirement '(user-processes))
+                 (modules `((srfi srfi-1)
+                            (srfi srfi-26)
+                            (ice-9 popen)  ;for the 'schedule' action
+                            (ice-9 rdelim)
+                            (ice-9 match)
+                            ,@%default-modules))
+                 (start #~(make-forkexec-constructor
+                           (list (string-append #$mcron "/bin/mcron")
+                                 #$@(if log?
+                                        #~("--log" "--log-format" #$log-format)
+                                        #~())
+                                 #$@files)
+
+                           ;; Disable auto-compilation of the job files and
+                           ;; set a sane value for 'PATH'.
+                           #:environment-variables
+                           (cons* "GUILE_AUTO_COMPILE=0"
+                                  "PATH=/run/current-system/profile/bin"
+                                  (remove (cut string-prefix? "PATH=" <>)
+                                          (environ)))
+
+                           #:log-file "/var/log/mcron.log"))
+                 (stop #~(make-kill-destructor))
+                 (actions
+                  (list (shepherd-schedule-action mcron files)))))))))
 
 (define mcron-service-type
   (service-type (name 'mcron)
-- 
2.39.1





This bug report was last modified 2 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.