[systemd-devel] How do I create/destroy instances dynamically when config files appear/disappear?

John Ioannidis systemd-devel at tla.org
Tue Mar 20 15:05:59 UTC 2018


On Tue, Mar 20, 2018 at 8:47 AM, Andrei Borzenkov <arvidjaar at gmail.com>
wrote:

> On Tue, Mar 20, 2018 at 12:52 AM, John Ioannidis <systemd-devel at tla.org>
> wrote:
>
>
> > I can get them to start the first time, but they do not stop when
> > configuration files change. If I systemctl daemon-reload, the links in
> > /run/systemd/system-generators get properly adjusted,
>
> generators are simply not the right tool for dynamic changes. There
> are path units for activating units when files appear but there are no
> corresponding mechanism to stop them.
>
>
>
Interesting... I didn't realize this. How about this as a workaround:

* letters-watcher.path watches /var/letters for any changes, and starts
(oneshot) letters-watcher.service

* letters-watcher.service scans the configuration file, determines what
instances it should kill and what it should create, and does so, either by
invoking systemctl or by talking to DBUS.

(I did a quick-and-dirty POC and it works, I'm wondering if this is the
right way, for some value of "right")

What I forgot to mention is that the files in the configuration directory
(/var/letters in the example) get pushed with sftp from a central location,
they are not created locally. What I'm trying to avoid is to replicate
existing systemd functionality, plus I'm looking at this as an opportunity
to learn more about systemd (greybeard and old-time systems engineer here,
but never too old to learn new stuff :) )

Many thanks,

/ji
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180320/f86dbe60/attachment.html>


More information about the systemd-devel mailing list