01.07.2016 00:50, Paul Menzel пишет: > Dear Michael, dear Andrei, > > > Thank you for replying. > > > Am Montag, den 27.06.2016, 15:37 +0200 schrieb Michael Biebl: >> 2016-06-27 13:49 GMT+02:00 Andrei Borzenkov <arvidj...@gmail.com>: >>> On Mon, Jun 27, 2016 at 9:25 AM, Paul Menzel wrote: > >>>> having a template for a service unit like `example@.service`, and >>>> starting several services from it, is there a way, to let another >>>> service unit require all services started from that template? >>> >>> I do not think it is possible. In other direction it may work with >>> some workaround (i.e. make every instance of template be required >>> by specific services). >> >> PartOf= in the template service might be what you are looking for. > > From the manual page systemd.unit: > >> PartOf= >> Configures dependencies similar to Requires=, but limited >> to stopping and restarting of units. When systemd stops or restarts >> the units listed here, the action is propagated to this unit. Note >> that this is a one-way dependency — changes to this unit do not >> affect the listed units. > > So, it could indeed be what I am looking for. In my use case, it > doesn’t feel right yet though. > > There are several instances of a Web application started from > example@.service. In front of it is the proxy HAProxy. > > So in my reading, saying that the Web application instances is a *part > of* HAProxy, doesn’t totally feel/sound right to me. > > Also, asking for `Requires=` was, that HAProxy seems to check the > configured backends to run, and refuses to start if they don’t. That’s > why, all the Web applications are required before the HAProxy start-up. > > If I am not mistaken, `PartOf=` does not solve that problem. > > Do you have another suggestion? >
This is exact use case I meant. Put [Install] RequiredBy=HAProxy.service in example@.service template; then "systemctl enable example@instance.service" will automatically add link to .../HAProxy.service.requires directory. Downside is that you need to statically configure all instances but as I understand HAProxy must know them in advance anyway. In principle, I do not see why we cannot have WantedBy and RequiredBy as first class directives under [Unit] to spare all these hoops.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel