From patchwork Sat Mar 22 11:36:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 40597 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 6C90D27BBE9; Sat, 22 Mar 2025 11:39:03 +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=unavailable 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 E877327BBE2 for ; Sat, 22 Mar 2025 11:39:02 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tvxBP-0002FJ-RA; Sat, 22 Mar 2025 07:38:31 -0400 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 1tvxB8-0001qP-Sv for guix-patches@gnu.org; Sat, 22 Mar 2025 07:38:15 -0400 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 1tvxB4-00008a-M9; Sat, 22 Mar 2025 07:38:12 -0400 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=R+pLjTM5mgdfIeQiOCzWOw88mhx3xEQaNcOS0HOnIWA=; b=lMFdmh0NYtKFyczOK/35cRiJ/SvfqPCaetQW6n9mKkFKDbjhh2ny34UwrNHJ/TS7eij5Dw4WQxGEK79YXsCXgRZ9axwOc8MmbN4lSHUU4Ry0VXIQI3HebhvX2USWBcQglUgIsxegnWrgourlPqsqSDmvrtdBcWiEkVzebF2M18GOiCSdXDAv7cQQJsKN6gVf2rqPyPdyGHkdTbRBE+m/VshX3pgt+sNGpcvDJu4c1FXNS/MXP+5xTDaD6qa0OOut9y6P3p2ay+rDbVfc47cbZm9xLcOjlQdkzzJzuBOrzKspHNDBRMRJdICCxOn7xSF7goO3P9LGiGuOY/LPYWvmug==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tvxB3-0002a0-2r; Sat, 22 Mar 2025 07:38:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77041] [PATCH v2 15/16] services: shepherd: Add =?utf-8?b?4oCY?= =?utf-8?b?c2hlcGhlcmQtdGltZXLigJku?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: andrew@trop.in, janneke@gnu.org, ludo@gnu.org, tanguy@bioneland.org, guix-patches@gnu.org Resent-Date: Sat, 22 Mar 2025 11:38:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77041 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77041@debbugs.gnu.org Cc: Luis Guilherme Coelho , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Andrew Tropin , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Tanguy Le Carrour X-Debbugs-Original-Xcc: Andrew Tropin , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Tanguy Le Carrour Received: via spool by 77041-submit@debbugs.gnu.org id=B77041.17426434699766 (code B ref 77041); Sat, 22 Mar 2025 11:38:09 +0000 Received: (at 77041) by debbugs.gnu.org; 22 Mar 2025 11:37:49 +0000 Received: from localhost ([127.0.0.1]:41201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tvxAi-0002XM-Sq for submit@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54284) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tvxAd-0002VW-MM for 77041@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:44 -0400 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 1tvxAY-0008Vr-55; Sat, 22 Mar 2025 07:37:38 -0400 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=R+pLjTM5mgdfIeQiOCzWOw88mhx3xEQaNcOS0HOnIWA=; b=LXhI9AS+6LtfgN5RD6zm DKpT9BZetwsOLMgVWHXGdURXh/TIzb+Rp6S7/YKatqfV0BoC7B9Qkp5HMgHkuaT8nrx9e5QRH7/PC 7Z6sRu8a1TRgWDs0uQM8Pc6aLPkyVEmCza+zuhML9aprGPI6rEaXZPzPFdKOGT1YJcHQVe4g4ZSIM WVrEfAAdGCBuv3z8CWdcJ9H1WXUVQ4fFrSy22da6xEI09fLg6yqXyLysQ0xnaGTrJ/CjzPIXtUzry lV1A8KLfolIU8GigrSPvlHhJ6TUaFaHAxZFJLEgZZ2dOlBVTn3wzZOTXPCNMTaOZO2Qx2rlnqjMBw 2hIfnSwuEfcVqA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 22 Mar 2025 12:36:52 +0100 Message-ID: X-Mailer: git-send-email 2.48.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 * gnu/services/shepherd.scm (shepherd-timer): New procedure. * gnu/home/services/shepherd.scm: Re-export it. Suggested-by: Luis Guilherme Coelho Change-Id: I5f702d4119eee47381a7a1ac650b8ad3fc5e6cdd --- gnu/home/services/shepherd.scm | 3 ++- gnu/services/shepherd.scm | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm index 25f1641b32..b4d826f6bb 100644 --- a/gnu/home/services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -53,7 +53,8 @@ (define-module (gnu home services shepherd) shepherd-action shepherd-configuration-action - shepherd-trigger-action)) + shepherd-trigger-action + shepherd-timer)) (define-record-type* home-shepherd-configuration make-home-shepherd-configuration diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index e7e414b920..c8e01c9d83 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -72,6 +72,7 @@ (define-module (gnu services shepherd) shepherd-action-procedure shepherd-configuration-action + shepherd-timer shepherd-trigger-action %default-modules @@ -257,6 +258,31 @@ (define (shepherd-service-canonical-name service) "Return the 'canonical name' of SERVICE." (first (shepherd-service-provision service))) +(define %default-timer-documentation + "Periodically run a command.") ;no i18n since it gets in the shepherd process + +(define* (shepherd-timer provision schedule command + #:key + (requirement '()) + (documentation %default-timer-documentation)) + "Return a Shepherd service with the given PROVISION periodically running +COMMAND, a list-valued gexp, according to SCHEDULE, a string in Vixie cron +syntax or a gexp providing a Shepherd calendar event. DOCUMENTATION is the +string that appears when running 'herd doc SERVICE'." + (shepherd-service + (provision provision) + (requirement requirement) + (modules '((shepherd service timer))) + (start #~(make-timer-constructor + #$(if (string? schedule) + #~(cron-string->calendar-event #$schedule) + schedule) + (command '(#$@command)) + #:wait-for-termination? #t)) + (stop #~(make-timer-destructor)) + (documentation documentation) + (actions (list shepherd-trigger-action)))) + (define (assert-valid-graph services) "Raise an error if SERVICES does not define a valid shepherd service graph, for instance if a service requires a nonexistent service, or if more than one