From e73cf57a204f2bf430c90930394afa08e9ec3399 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 17 Jan 2025 22:34:50 +0100 Subject: services: shepherd: Add ‘transient’ and ‘timer’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/shepherd.scm (shepherd-timer-service-type) (shepherd-transient-service-type): New variables. * doc/guix.texi (Shepherd Services): Document them. Change-Id: I9b622e7e947e7a6384c2701a313d0c7080a0a5f6 --- gnu/services/shepherd.scm | 54 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index 0de3c9c55c5..5f2625ac20e 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2016, 2018-2024 Ludovic Courtès +;;; Copyright © 2013-2016, 2018-2025 Ludovic Courtès ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2018 Carlo Zancanaro ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen @@ -81,6 +81,8 @@ shepherd-service-upgrade user-processes-service-type + shepherd-timer-service-type + shepherd-transient-service-type assert-valid-graph)) @@ -668,4 +670,52 @@ read-only, just before rebooting/halting. Processes still running after a few seconds after @code{SIGTERM} has been sent are terminated with @code{SIGKILL}."))) -;;; shepherd.scm ends here + +;;; +;;; Timer and transient service maker. +;;; + +(define shepherd-timer-service-type + (shepherd-service-type + 'shepherd-timer + (const (shepherd-service + (provision '(timer)) + (requirement '(user-processes)) + (modules '((shepherd service timer))) + (free-form #~(timer-service + '#$provision + #:requirement '#$requirement)))) + #t ;ignored + (description "The Shepherd @code{timer} service lets you schedule commands +dynamically, similar to the @code{at} command that your grandparents would use +on that Slackware they got on a floppy disk. For example, consider this +command: + +@example +herd schedule timer at 07:00 -- mpg123 Music/alarm.mp3 +@end example + +It does exactly what you would expect."))) + +(define shepherd-transient-service-type + (shepherd-service-type + 'shepherd-transient + (const (shepherd-service + (provision '(transient)) + (requirement '(user-processes)) + (modules '((shepherd service transient))) + (free-form #~(transient-service + '#$provision + #:requirement '#$requirement)))) + #t ;ignored + (description "The Shepherd @code{transient} service lets you run commands +asynchronously, in the background, similar to @command{systemd-run}, as in +this example: + +@example +herd spawn transient -E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \\ + rsync -e ssh -vur . backup.example.org: +@end example + +This runs @command{rsync} in the background, as a service that you can inspect +with @command{herd status} and stop with @command{herd stop}."))) -- cgit v1.3