mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 13:36:36 +01:00
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
This commit is contained in:
parent
4cef56587a
commit
100c1e1adf
2 changed files with 22 additions and 8 deletions
|
@ -21085,8 +21085,9 @@ Age in seconds after which a file is subject to deletion (six months by
|
|||
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}).
|
||||
Schedule of the log cleanup job written either as 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
|
||||
|
||||
|
|
|
@ -385,18 +385,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)))))
|
||||
(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.")))
|
||||
|
||||
|
|
Loading…
Reference in a new issue