How to stop unneeded services?

Stephen Gallagher sgallagh at redhat.com
Fri Nov 21 20:25:15 UTC 2014




On Fri, 2014-11-21 at 13:52 +0400, Peter Lemenkov wrote:
> Hello All!
> Perhaps a silly question but I'm stuck and need your help, my fellow fedorians.
> 
> I've got a service foo.service which Requires=bar.socket (which in
> turn runs bar.service). So if I start foo.service then systemd opens
> bar.socket, captures first packet and runs bar.service (which isn't
> intended to be started manually btw). So far everything works as
> expected.
> 
> I was asked if it's possible to automatically stop bar.service (and
> bar.socket) if no services which requires these two are active. I
> played with StopWhenUnneeded +
> BindsTo but without much success.
> 
> I believe this sounds like a generic pattern so perhaps someone
> already implemented it. Could somebody point me on working example?
> Any other help would be greatly appreciated.


I'm not an expert on the matter, but in general I think usually the
bar.service has to be modified such that it *automatically* exits when
it's not in use. Then systemd will autostart it whenever the socket is
opened and then after some reasonable wait-time, the service will exit
until the next time it's auto-started.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.fedoraproject.org/pipermail/devel/attachments/20141121/660b7f82/attachment-0001.sig>


More information about the devel mailing list