From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-devel-bounces+larch=yhetil.org@gnu.org>
Received: from mp1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms8.migadu.com with LMTPS
	id 6MWqATiZAGboNAEA62LTzQ:P1
	(envelope-from <guix-devel-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 24 Mar 2024 22:20:56 +0100
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1.migadu.com with LMTPS
	id 6MWqATiZAGboNAEA62LTzQ
	(envelope-from <guix-devel-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 24 Mar 2024 22:20:56 +0100
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=etD0B4yP;
	spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=gnu.org
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1711315255;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:list-id:list-help:
	 list-unsubscribe:list-subscribe:list-post:dkim-signature;
	bh=nwS6tmPqbQsqotgY2c2urn19CMx5quM0StH+GOMHIoQ=;
	b=cTLtQVUyUZFYDyJaxUBMSd2WKixtfxbTp2jWcy1/uxLvocXYW3XGyo3gUaDQKxO2rXIxfJ
	W9FY/h2oCqBHIItHdEtNY/K8KVPS8ZMWUf1IzwkzxENpc4JulZIPKVq1udAL5h9mghfSl4
	SnbJ/F9h/fZc/+MSaXlQOrXRHGsguIMVw/mx83u4btANm82+oxEt9OmOyOYAGvcW+1GuK7
	y2/KpsLGgFqpMRKnCFkDNGgtQLWyvk85ROlMUzZunqJh3y1xtwVNYSbAOIv3aQEA++socF
	6RXh0me3+DAW2osaJse/Qt107l2nZfVV1MuocTEysGqK2egeYq/Xia4aSx20+Q==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=etD0B4yP;
	spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=gnu.org
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1711315255; a=rsa-sha256; cv=none;
	b=Ej057YImzUSYYu1WNaYMCbCLoXOzu+TQp6Wvl9Tuu8eWRgU7HSxcObyt296xkONfZr8Fyy
	AKpIeiRNAewUAmFnpFRBWdMnPK660NPa3j+BP9gPX7LnN9T/4me64d3cgCEhMd/mn9Tvzw
	lHFl1l+/AYq0QX27nOp4b+3HpcFj459uTBQ43dikAY5IZHigKxCW6bRzXc5j1B89WkHqHG
	zZ6VxKZ+IOGGJYI6ZkLG0Lv3z2ZFzn3dp1zMKIcW+SlXCESsmpfRFU0wbtM9GKMqFfW2t+
	D0WgPNGVU7ePCGAZ7aRQ5iiVv0RJTU02SmZ38QuNRF8JjS5gaJTG8b//knCa0w==
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 9CFAE5AB71
	for <larch@yhetil.org>; Sun, 24 Mar 2024 22:20:55 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-devel-bounces@gnu.org>)
	id 1roVGU-0001NK-BP; Sun, 24 Mar 2024 17:20:26 -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 <ludo@gnu.org>) id 1roVGR-0001NA-L2
 for guix-devel@gnu.org; Sun, 24 Mar 2024 17:20:24 -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 <ludo@gnu.org>) id 1roVGR-0003IB-Cw
 for guix-devel@gnu.org; Sun, 24 Mar 2024 17:20:23 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to:
 references; bh=nwS6tmPqbQsqotgY2c2urn19CMx5quM0StH+GOMHIoQ=; b=etD0B4yPRytCUu
 0Qhv262rJJwMC2CrYuF647ctALtGOzhL9IPH00P/jFxUsDoYk1Yp/Bxciw1MT4McbDUGlOLdO+1kf
 MEJ5HFi+eDvSIUBLy91s8pmrngJAYpecTGJhSR9kWoLvVgaT0pw5rNutaVtAR37DOpRaZOzEoVjXG
 cnLdI11NM2sLVV9Pb++UlKxqV4dKCyIY0cn2McTJfm6Drb5dyvIaombywO92COG4prxePC6ZvOG/P
 OBSRih/SsMAOLAP0ItmqFY7SZWFsMMThowSnO5w42GpNOikw6cLUeHMsjMYwaoWD4QKp3MJou1VOn
 LvUnuVGCZMtM/vaO6oSg==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@gnu.org>
To: Guix Devel <guix-devel@gnu.org>
Subject: Shepherd timers
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Quintidi 5 Germinal an 232 de la =?utf-8?Q?R=C3=A9vo?=
 =?utf-8?Q?lution=2C?= jour de la Poule
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Sun, 24 Mar 2024 22:20:04 +0100
Message-ID: <87jzlrpbsr.fsf@gnu.org>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-BeenThere: guix-devel@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Development of GNU Guix and the GNU System distribution."
 <guix-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-devel>,
 <mailto:guix-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guix-devel>
List-Post: <mailto:guix-devel@gnu.org>
List-Help: <mailto:guix-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-devel>,
 <mailto:guix-devel-request@gnu.org?subject=subscribe>
Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org
Sender: guix-devel-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Queue-Id: 9CFAE5AB71
X-Spam-Score: -11.08
X-Migadu-Spam-Score: -11.08
X-Migadu-Scanner: mx11.migadu.com
X-TUID: //NeUOb+Oxqq

Hello Guix!

I pushed to the =E2=80=98devel=E2=80=99 branch of the Shepherd a new module=
 that
implements =E2=80=9Ctimers=E2=80=9D along with =E2=80=98herd=E2=80=99 suppo=
rt to display information
about them.

It lets you provide configuration like this one:

--8<---------------cut here---------------start------------->8---
(use-modules (shepherd service timer))

(define timer
  (service '(my-timer)
           #:start (make-timer-constructor
                    (calendar-event #:seconds '(0 7 15 22 30 45))
                    (command '("sh" "-c" "echo Hi from $PWD.; sleep 20; ech=
o done")))
           #:stop (make-timer-destructor)))

(register-services (list timer))
(start-in-the-background '(my-timer))
--8<---------------cut here---------------end--------------->8---

And then =E2=80=98my-timer=E2=80=99 invokes the given command at the moment=
s that match
the constraints defined by =E2=80=98calendar-event=E2=80=99=E2=80=94in this=
 case any time the
number of seconds is equal to 0, 7, 15, 22, 30, or 45.  You can also
make it every Monday at 9AM etc., as you would expect.

The =E2=80=98herd=E2=80=99 command provides details information about the t=
imer:

--8<---------------cut here---------------start------------->8---
$ ./herd -s sock status my-timer
Status of my-timer:
  It is running since 21:09:32 (68 seconds ago).
  Timed service.
  Periodically running: sh -c "echo Hi from $PWD.; sleep 20; echo done".
  Child process: 1814
  It is enabled.
  Provides (my-timer).
  Requires ().
  Will not be respawned.

Recent runs:
  2024-03-24 21:10:04 Process exited successfully.
  2024-03-24 21:10:19 Process exited successfully.
  2024-03-24 21:10:26 Process exited successfully.
  2024-03-24 21:10:34 Process exited successfully.
  2024-03-24 21:10:35 Process terminated with signal 15.

Recent messages:
  2024-03-24 21:10:29 Hi from /home/ludo.

Upcoming timer alarms:
  21:10:45 (in 5 seconds)
  21:11:00 (in 20 seconds)
  21:11:07 (in 27 seconds)
  21:11:15 (in 35 seconds)
  21:11:22 (in 42 seconds)
--8<---------------cut here---------------end--------------->8---

And of course you can do anything you can do with a service: stop it,
unload it, load a replacement, and so on.

Feedback & suggestions welcome!

Ludo=E2=80=99.