[systemd-devel] systemd and templates

Mathieu Bridon bochecha at fedoraproject.org
Mon Jun 25 01:47:22 PDT 2012


On Mon, 2012-06-25 at 09:43 +0200, Michal Sekletar wrote:
> Also it should be possible to group more instances together
> and control them as a group. In such case template service will
> contain WantedBy= option, where some other target should be specified,
> e.g. opevpn.target.  However, instances should start/stop whenever the
> target is started/stopped. Therefore we need to configure some type of
> dependency between template and target in [Unit] section. Currently we
> don't have a dependency type which is suitable for this scenario.

You could use StopWhenUnneeded=yes for that, and stopping the target
will stop all the corresponding services.

However...

> We
> could use Requires or BindTo, and it will work in case where, one will
> stop target and all associated instances will be stopped as well,
> but on the other hand starting one instance will pull in target and
> all instances.

.. if you start manually a service which has the StopWhenUnneeded=yes
directive and its WantedBy target isn't running, then the service exits
instantly (it is unneeded).

So that's a different compromise from the one you were mentioning, but
maybe it works for your use case (at least it works for mine).


-- 
Mathieu




More information about the systemd-devel mailing list