How do I create/destroy instances dynamically when config files appear/disappear?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Di, 20.03.18 11:05, John Ioannidis (systemd-devel at tla.org) wrote:

> 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")

That sounds like an OK approach. It's definitely intended mode of
operation to use unit instances to quickly start/stop instances
on-the-fly without installing/removing any unit files/symlinks for
them each time. Just install the template unit file, and start/stop
instances off it as needed. That way you don't ever need to change
systemd configuration, and never reload PID 1.

Lennart

-- 
Lennart Poettering, Red Hat


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux