From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oF1cLamMIGQ/CwAASxT56A (envelope-from ) for ; Sun, 26 Mar 2023 20:19:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CAZMLamMIGR25gAA9RJhRA (envelope-from ) for ; Sun, 26 Mar 2023 20:19:21 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 39ECE58B for ; Sun, 26 Mar 2023 20:19:21 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679854761; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aIEFcFdH5AT/T2ejNV391eBCRwKmVX9eVPmo4Che5jA=; b=cJNnKFdaT7bdRBgu99YtXNPmYMDRei5JVtGhVEm97atYQctBOahlTGBtlNKtvKSSqy7zjN LZQ58UvqNpyeuLJwOSdqwbjI1lOhwqP4L5zPTXCNSzQF1EFsQ3Kp4JxaQN6+CyKrOzOFz5 SvsxwyNHP8Pa6MYQYWv/QNS0KUZkll5etyQyHRTZ8bPCg/UmPFpMHoGFwYmVOJ4dmXvCKv 35ugANISxnn8oSz62nKamIXKFZLPZMFVwzhJiFtViNmpaZUoPNAgYU+nELgV41l15xetcX ezvp4vN97f4pT92dkBEJmGu9Y0lD1+m/dnNdN+BbDUY1NK6q4LpNxA+UtYURpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679854761; a=rsa-sha256; cv=none; b=eNP4Hikigkx7vsT2Gf7jSJboF9vUAixjJd0ZNzJCpQljAEmeAKnHiam7PJZG4KuNi9iAi3 aaoTUlVQaa278NHWI26NhjpHoD//PU0PqqvFmSxZJc9Qip23zSzF8EOBdDA1I4uBHsPB3D PCHZ7fML6XiZTt6p/t3U4ap81ZzbacWj0X/UhclLtZL+8RKlpioEl6aMIsP0101LqGgika JThqIe78b+++Vr7fY0Q7e+V/GkSr6W0bRMEGF0V2TMU98cJZwVzMHk83QNdzSCsZgZHuI1 t2mquqQHC9FMWCYcfa5eiZDkuVm1VHm0xHDt6dDJxfLFLY6qcBR6457PoFnBDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgUxM-00031F-7t; Sun, 26 Mar 2023 14:19:04 -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 1pgUxL-000316-6O for guix-patches@gnu.org; Sun, 26 Mar 2023 14:19:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pgUxK-0006Jd-LH for guix-patches@gnu.org; Sun, 26 Mar 2023 14:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pgUxK-0002Zh-8n; Sun, 26 Mar 2023 14:19:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62465] [PATCH] services: mcron: Add instance name support for mcron. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sun, 26 Mar 2023 18:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62465 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62465@debbugs.gnu.org Cc: Bruno Victal , maxim.cournoyer@gmail.com X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: maxim.cournoyer@gmail.com Received: via spool by submit@debbugs.gnu.org id=B.16798547269873 (code B ref -1); Sun, 26 Mar 2023 18:19:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Mar 2023 18:18:46 +0000 Received: from localhost ([127.0.0.1]:45776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgUx3-0002ZB-RZ for submit@debbugs.gnu.org; Sun, 26 Mar 2023 14:18:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:50520) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgUx2-0002Z1-Bs for submit@debbugs.gnu.org; Sun, 26 Mar 2023 14:18:44 -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 1pgUx1-0002yT-Va for guix-patches@gnu.org; Sun, 26 Mar 2023 14:18:43 -0400 Received: from smtpm1.myservices.hosting ([185.26.105.232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgUwz-0006HT-Tk for guix-patches@gnu.org; Sun, 26 Mar 2023 14:18:43 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm1.myservices.hosting (Postfix) with ESMTP id B74CA202E5 for ; Sun, 26 Mar 2023 20:18:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 52D3F800A9; Sun, 26 Mar 2023 20:18:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4y3TgJg0ssaJ; Sun, 26 Mar 2023 20:18:38 +0200 (CEST) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id E5E91800A8; Sun, 26 Mar 2023 20:18:37 +0200 (CEST) From: Bruno Victal Date: Sun, 26 Mar 2023 19:18:25 +0100 Message-Id: <47e924fd42f74fc2800dc64399f7a069ad463515.1679854500.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.26.105.232; envelope-from=mirai@makinata.eu; helo=smtpm1.myservices.hosting X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: X-Migadu-Queue-Id: 39ECE58B X-Spam-Score: -1.23 X-Migadu-Spam-Score: -1.23 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: bxNzYFlXQ8V3 Allow running more than one mcron instance. Follow-up to . * gnu/services/mcron.scm (mcron-configuration)[instance-name]: New field. (shepherd-schedule-action): Implement instance-name support. * doc/guix.texi (Scheduled Job Execution): Update it. --- doc/guix.texi | 26 ++++++++++++++++++++++++++ gnu/services/mcron.scm | 16 +++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3e335306f1..0f735489d5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19376,6 +19376,10 @@ Scheduled Job Execution @item @code{mcron} (default: @code{mcron}) (type: file-like) The mcron package to use. +@item @code{instance} (type: maybe-symbol) +Set the shepherd service name to @code{mcron-@var{instance}}. This is +useful when you want to have more than one mcron instance. + @item @code{jobs} (default: @code{()}) (type: list-of-gexps) This is a list of gexps (@pxref{G-Expressions}), where each gexp corresponds to an mcron job specification (@pxref{Syntax, mcron job @@ -19400,6 +19404,28 @@ Scheduled Job Execution @end deftp @c %end of fragment +Occasionally, it is desirable to run another mcron instance to separate +some of the jobs from the main mcron instance for clarity purposes, or if +the jobs are very chatty and frequent. (for example, a heartbeat check +every 30 seconds) + +The example below shows how an extra mcron service can be defined. +@lisp +(use (guix) + (guix records) + (gnu services) + (gnu services mcron)) + +(define secondary-mcron-service-type + (service-type + (inherit mcron-service-type) + (name 'mcron-secondary) + (default-value + (mcron-configuration + (instance 'secondary) + (log-file "/var/log/mcron-secondary.log"))))) +@end lisp + @node Log Rotation @subsection Log Rotation diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index 2ef5980e09..c949f1aebc 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -27,6 +27,7 @@ (define-module (gnu services mcron) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:export (mcron-configuration @@ -59,12 +60,18 @@ (define list-of-gexps? (list-of gexp?)) (define-maybe/no-serialization string) +(define-maybe/no-serialization symbol) (define-configuration/no-serialization mcron-configuration (mcron (file-like mcron) "The mcron package to use.") + (instance + maybe-symbol + "Set the shepherd service name to @code{mcron-@var{instance}}. +This is useful when you want to have more than one mcron instance.") + (jobs (list-of-gexps '()) "This is a list of gexps (@pxref{G-Expressions}), where each gexp @@ -158,12 +165,15 @@ (define (shepherd-schedule-action mcron files) (define (mcron-shepherd-services config) (match-record config - (mcron jobs log? log-file log-format date-format) + (mcron jobs log? log-file log-format date-format instance) (if (eq? jobs '()) '() ;nothing to do - (let ((files (job-files mcron jobs))) + (let ((files (job-files mcron jobs)) + (service-name + (string->symbol + (format #f "mcron~@[-~a~]" (maybe-value instance))))) (list (shepherd-service - (provision '(mcron)) + (provision (list service-name)) (requirement '(user-processes)) (modules `((srfi srfi-1) (srfi srfi-26) -- 2.39.1