[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd t
From: |
Ludovic Courtès |
Subject: |
[bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer. |
Date: |
Fri, 13 Dec 2024 23:58:23 +0100 |
This is a semi-incompatible change: gexps previously provided in the
‘schedule’ field will no longer work.
* gnu/services/admin.scm (log-cleanup-mcron-jobs): Remove.
(log-cleanup-shepherd-services): New procedure.
(log-cleanup-service-type): Extend SHEPHERD-ROOT-SERVICE-TYPE instead of
MCRON-SERVICE-TYPE.
* doc/guix.texi (Log Rotation): Adjust ‘schedule’ documentation
accordingly.
Change-Id: I2a3beb7dffbc9992b714a29423674db9c7dc6cab
---
doc/guix.texi | 5 +++--
gnu/services/admin.scm | 25 +++++++++++++++++++------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 89a85961ac..e7784404d6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20973,8 +20973,9 @@ Log Rotation
default).
@item @code{schedule} (default: @code{"30 12 01,08,15,22 * *"})
-String or gexp denoting the corresponding mcron job schedule
-(@pxref{Scheduled Job Execution}).
+This is the schedule of the log cleanup job written either a string in
+traditional cron syntax or as a gexp representing a Shepherd calendar
+event (@pxref{Timers,,, shepherd, The GNU Shepherd Manual}).
@end table
@end deftp
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 5e1c197d78..aa1f56e90a 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -349,18 +349,31 @@ (define (log-cleanup-program directory expiry)
(length logs) #$directory)
(for-each delete-file logs))))))
-(define (log-cleanup-mcron-jobs configuration)
+(define (log-cleanup-shepherd-services configuration)
(match-record configuration <log-cleanup-configuration>
- (directory expiry schedule)
- (list #~(job #$schedule
- #$(log-cleanup-program directory expiry)))))
+ (directory expiry schedule)
+ (let ((program (log-cleanup-program directory expiry)))
+ (list (shepherd-service
+ (provision '(log-cleanup))
+ (requirement '(user-processes))
+ (modules '((shepherd service timer)))
+ (start #~(make-timer-constructor
+ #$(if (string? schedule)
+ #~(cron-string->calendar-event #$schedule)
+ schedule)
+ (command '(#$program))))
+ (stop #~(make-timer-destructor))
+ (actions (list (shepherd-action
+ (name 'trigger)
+ (documentation "Trigger log cleanup.")
+ (procedure #~trigger-timer)))))))))
(define log-cleanup-service-type
(service-type
(name 'log-cleanup)
(extensions
- (list (service-extension mcron-service-type
- log-cleanup-mcron-jobs)))
+ (list (service-extension shepherd-root-service-type
+ log-cleanup-shepherd-services)))
(description
"Periodically delete old log files.")))
--
2.46.0
- [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service, Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 04/10] services: unattended-upgrade: Rewrite as a Shepherd timer., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer.,
Ludovic Courtès <=
- [bug#74860] [PATCH 08/10] home: services: Add log rotation service., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 06/10] services: rottlog: Deprecate., Ludovic Courtès, 2024/12/13
- [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service, Ludovic Courtès, 2024/12/13