[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Announcing shepherd-run
From: |
Ludovic Courtès |
Subject: |
Re: Announcing shepherd-run |
Date: |
Thu, 28 Nov 2024 09:10:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi!
Efraim Flashner <efraim@flashner.co.il> skribis:
> 0.2.0 is now out!
> 100% fewer GOOPS!
> 'shepherd-run --version' now returns the correct string!
Wo0t!
Inspired by shepherd-run, I thought “hey let’s add this to Shepherd
proper for 1.0, easy!”. Turns out that finding a way to pass the
various options (‘-d’, ‘-E’, etc.) to the action that spawns a service
was still an open issue. Solution: add these options to ‘herd’, and
have it pass them as keyword arguments to the action that’s invoked.
That’s allowed me to unify ‘herd schedule timer’ and the new ‘herd spawn
transient’ (the name of the Awk-less GOOPS-less C-less ‘systemd-run’).
Here’s the doc:
--8<---------------cut here---------------start------------->8---
The “transient service maker” lets you run commands in the background,
and it does so by wrapping those commands in transient services (*note
Defining Services::). It is similar to the ‘systemd-run’
(https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html)
command, which you might have encountered before.
A simple configuration file that uses this service looks like this:
(use-modules (shepherd service transient))
(register-services (list (transient-service)))
This creates a service called ‘transient’ that has a ‘spawn’ action,
which you can use like this:
# Run 'make' from the current directory.
herd spawn transient -d "$PWD" -- make -j4
# Run 'rsync' from the home directory, inheriting
# the 'SSH_AUTH_SOCK' environment variable.
herd spawn transient \
--log-file=backup.log \
-E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \
rsync -e ssh -vur . backup.example.org:
Each of these ‘herd spawn transient’ commands creates a new transient
service. Like any other service, they can be inspected and stopped.
Running ‘herd stop transient’ stops all the currently running
transients.
The command runs from the directory specified by
‘default-service-directory’ or from that specified by the
‘--working-directory’ option of ‘herd’; it has with the environment
variables in ‘default-environment-variables’, augmented with ‘HOME’ when
running as a different user, with the addition of variables passed with
‘--environment-variable’. *Note Invoking herd::, for more info on
influential command-line options.
-- Procedure: transient-service [PROVISION] [#:requirement '()]
Return a service with the given PROVISION and REQUIREMENT. The
service has a ‘spawn’ action that lets users run commands in the
background.
--8<---------------cut here---------------end--------------->8---
It’s too big a change in between two release candidates, but it seemed
better to get that right before 1.0.
Lemme know what you think!
Ludo’.
Re: Announcing shepherd-run, Efraim Flashner, 2024/11/21
- Re: Announcing shepherd-run,
Ludovic Courtès <=