Systemd unit file implementation questions (ypbind)

Michal Hlavinka mhlavink at redhat.com
Mon Apr 18 08:50:26 UTC 2011


> > > now, if you shut down A with "systemctl stop A", this will also stop B,
> > > and it will do so in the inverse starting order. i.e. stop B first, stop
> > > A second. BindTo= would do exactly the same here. The difference now
> > > comes if for some reason A dies independently of anybody running
> > > "systemctl stop A": should we then shut down B retroactviely? The
> > > ordering would normally suggest that B goes down before A, but if A just
> > > goes away on its own, then should we still shut down B? If you use
> > > BindTo= that's what would happen. If you use Requires= it wouldn't.
> > 
> > That's not exactly what I'd like to know. Lets say there are services A and B.
> > When B is started, A must be running, so B requires A, but when B is stopped, 
> > it should stop A. So A is started only on demand, but it should not be running 
> > if there is nothing that requires it.
> 
> In general we try to avoid work if we can. That includes that we don't
> stop services unless we have to. Often it is nicer to just leave a
> service running when it hangs in a poll() and is swapped out than to
> start/stop it all the time.
> 
> That said, systemd wouldn't be systemd if it wouldn't cover your case
> too, if you really want. Set "StopWhenUnneeded=yes" in a unit and it
> will be stopped as soon as nothing runs anymore that needs it. Defaults
> to "no".
> 
> But I think in the general case this isn't really something you want to
> use much.

There is a good reason for case where service need exclusive access to some 
resources (device,port,...), because you can't start different service until first 
one stops. For example with nut (ups daemon) driver must release ups device 
so when you want to try different ups daemon (for example apcupsd) ups 
device is not used by anything


More information about the devel mailing list