[systemd-devel] How to properly write an "umbrella" unit

Michael Biebl mbiebl at gmail.com
Tue Jul 21 12:42:38 PDT 2015


Have a look at the openvpn package in Debian. It implements something
like you have in mind.
There are multiple openvpn at .service instances and a single
openvpn.service which can be used by the admin to start/stop/restart
them.

2015-07-21 13:43 GMT+02:00 Marc Haber <mh+systemd-devel at zugschlus.de>:
> Hi,
>
> I am trying to systemd'ize a daemon which is useful to be run in two
> instances. It is usually the case that both instances need to be
> started and stopped simultaneously, and the local admin would want a
> _single_ command to start and stop both instances. Therefore, an
> "umbrella" is needed.
>
> As a beginner, I have written:
>
> nifty.target:
> [Unit]
> Description=nifty Server (all protocols)
> After=network.target
>
> [Install]
> WantedBy=multi-user.target
>
>
> nifty-v4.service:
> [Unit]
> Description=nifty Server for IPv4 (niftyd4.conf)
> After=network.target
> PartOf=nifty.target
>
> [Service]
> ExecStart=/usr/sbin/niftyd -f -4 -q -cf /etc/nifty/niftyd4.conf
>
> [Install]
> WantedBy=nifty.target
>
>
>
> nifty-v6.service:
> [Unit]
> Description=nifty Server for IPv6
> After=network.target
> PartOf=nifty.target
>
> [Service]
> ExecStart=/usr/sbin/niftyd -f -6 -q -cf /etc/nifty/niftyd6.conf
>
> [Install]
> WantedBy=nifty.target
>
>
> This works as designed. Unfortunately, my Distribution's build tools
> don't handle package-provided targets too well, and I feel that using
> a target here is kind of wrong anyway.
>
> Can I write my nifty.target as a service? I have seen in this case
> nifty.service files with Exec=/bin/true to basically create a no-op
> service, but that's ugly.
>
> If I move my service to a nifty at .service, how would I start two
> instances from a single shell command?
>
> How would one handle this situation in the clear, recommended way?
>
> Greetings
> Marc
>
> --
> -----------------------------------------------------------------------------
> Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
> Leimen, Germany    |  lose things."    Winona Ryder | Fon: *49 6224 1600402
> Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel



-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?


More information about the systemd-devel mailing list