unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 74860@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#74860] [PATCH v2 04/12] services: log-cleanup: Rewrite as a Shepherd timer.
Date: Wed,  8 Jan 2025 18:41:48 +0100	[thread overview]
Message-ID: <788340be0f08a348de1e1dcbd908019e24f465cf.1736357737.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1736357737.git.ludo@gnu.org>

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 f521a2d2ad..e1d08c2f10 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -21084,8 +21084,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}).
+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
 
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 @@ (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.47.1





  parent reply	other threads:[~2025-01-08 17:43 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’ Ludovic Courtès
2025-01-02 14:19   ` Maxim Cournoyer
2025-01-04 18:16     ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer Ludovic Courtès
2025-01-02 14:24   ` Maxim Cournoyer
2024-12-13 22:58 ` [bug#74860] [PATCH 04/10] services: unattended-upgrade: " Ludovic Courtès
2025-01-02 14:28   ` Maxim Cournoyer
2024-12-13 22:58 ` [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
2025-01-02 14:41   ` Maxim Cournoyer
2024-12-13 22:58 ` [bug#74860] [PATCH 06/10] services: rottlog: Deprecate Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
2024-12-14 18:34   ` pelzflorian (Florian Pelz)
2024-12-17 14:25     ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 08/10] home: services: Add log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’ Ludovic Courtès
2025-01-02 14:34   ` Maxim Cournoyer
2024-12-13 22:58 ` [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
2025-01-02 14:34   ` Maxim Cournoyer
2024-12-13 23:20 ` [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
2025-01-08 17:41 ` [bug#74860] [PATCH v2 00/12] " Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 01/12] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 02/12] system: Add zstd to ‘%base-packages’ Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 03/12] services: Add ‘log-rotation-service-type’ Ludovic Courtès
2025-01-08 17:41   ` Ludovic Courtès [this message]
2025-01-08 17:41   ` [bug#74860] [PATCH v2 05/12] services: unattended-upgrade: Rewrite as a Shepherd timer Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 06/12] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 07/12] services: rottlog: Deprecate Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 08/12] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 09/12] home: services: Add log rotation service Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 10/12] home: Define ‘%base-home-services’ Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 11/12] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
2025-01-08 17:41   ` [bug#74860] [PATCH v2 12/12] DRAFT news: Add entry for ‘%base-home-services’ Ludovic Courtès
2025-01-08 21:51 ` [bug#74860] [PATCH v3 00/12] Using the Shepherd's log rotation service Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 01/12] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 02/12] system: Add zstd to ‘%base-packages’ Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 03/12] services: Add ‘log-rotation-service-type’ Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 04/12] services: log-cleanup: Rewrite as a Shepherd timer Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 05/12] services: unattended-upgrade: " Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 06/12] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 07/12] services: rottlog: Deprecate Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 08/12] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 09/12] home: services: Add log rotation service Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 10/12] home: Define ‘%base-home-services’ Ludovic Courtès
2025-01-08 21:51   ` [bug#74860] [PATCH v3 11/12] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
2025-01-08 21:52   ` [bug#74860] [PATCH v3 12/12] DRAFT news: Add entry for ‘%base-home-services’ Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=788340be0f08a348de1e1dcbd908019e24f465cf.1736357737.git.ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=74860@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).