diff options
author | Ludovic Courtès <ludo@gnu.org> | 2024-12-11 19:48:57 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-01-16 22:30:02 +0100 |
commit | 100c1e1adf0ac170a4e10906abca81282cd993f3 (patch) | |
tree | 211583fd982bcc26619c1aa394aea42508d38728 /gnu | |
parent | 4cef56587a874d0e2cdd372b8887415cadbaedcc (diff) |
services: log-cleanup: Rewrite as a Shepherd timer.
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
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/services/admin.scm | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index deaa3b6c89..7d202d737e 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -385,18 +385,31 @@ Old log files are removed or compressed according to the configuration.") (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."))) |