From patchwork Wed Jan 8 21:51:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 36786 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4258527BBEA; Wed, 8 Jan 2025 21:54:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0957827BBE2 for ; Wed, 8 Jan 2025 21:54:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVe09-00008G-J9; Wed, 08 Jan 2025 16:54:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVe02-0008UR-81 for guix-patches@gnu.org; Wed, 08 Jan 2025 16:54:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVe01-0004Fz-Uh; Wed, 08 Jan 2025 16:54:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=Ybuk2RetGYS+YVsBjWOX8n0lzltYgSskKRb1HStkWyo=; b=vktHOrUFmYU5VQn+O1oQWfz4gABB+YOWC2QmwHGnkiRsBahMJmBglNKrffh7Xg5ocgxJBHsxMyY9kDri+5w6JGS4NvFk6wONdWfe5bi3C4JbMkyLYEXQyoBleDhWIEG/BeREsILjJsoUI84bxpVieJcvBG0apvgLH7oDsxHPwwCssEvnV162BMxcB2LiomfLj4OSNJ8kyGv8iFh4s5jERcyrBKPhnOJacRYlnAg8JeT6UJHxdy0Y9i3jrlTqJL25jYZX7Yjo01uvRQVrmEQRKPIMgRD/sjvNH4eNq/Ovj7o/gMPLD/SLfTs2J3MJpaZsP7mw3vPkCEWMOzR+73IJGg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tVe01-0005XI-PM; Wed, 08 Jan 2025 16:54:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74860] [PATCH v3 04/12] services: log-cleanup: Rewrite as a Shepherd timer. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 08 Jan 2025 21:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74860 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74860@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 74860-submit@debbugs.gnu.org id=B74860.173637318821137 (code B ref 74860); Wed, 08 Jan 2025 21:54:01 +0000 Received: (at 74860) by debbugs.gnu.org; 8 Jan 2025 21:53:08 +0000 Received: from localhost ([127.0.0.1]:49300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tVdz9-0005Ue-37 for submit@debbugs.gnu.org; Wed, 08 Jan 2025 16:53:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37976) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tVdz1-0005SZ-QL for 74860@debbugs.gnu.org; Wed, 08 Jan 2025 16:53:00 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVdyw-00045h-Hl; Wed, 08 Jan 2025 16:52:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=Ybuk2RetGYS+YVsBjWOX8n0lzltYgSskKRb1HStkWyo=; b=CYrighEuEMRi+UHB3bAc +212R/pjMsbSyvQivGlqELlMAQe3zhjGLmzkuRk/PVmrF7CgR2CSIuGs/BYUB3KMh5nzXrqrt60KV BRwQQHNqx0yOL3DKZG2YpEoLd1VQt05GydBW3qkqUe57ZeumAylwF7YOVEEAZyX6VEW7xSBJCDPSx qtsI+I3Tpjqu/hleWDn9SWU1P77s4ZfWJy5tg5xp6GtiUrDjdF+9iG9zK5Oy8K2RmLzicJqnUfI2F v6oQYMw06U1bGk5Jew/GVpoxPKe0Vh5yr//3uj7Ii2uGvGBWZeS+qhbu74cf5PcjIyAX1G5lsommA JCSKAOeWJRM/zw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 8 Jan 2025 22:51:52 +0100 Message-ID: <788340be0f08a348de1e1dcbd908019e24f465cf.1736373022.git.ludo@gnu.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 - (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.")))