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

Marc Haber mh+systemd-devel at zugschlus.de
Tue Jul 21 04:43:48 PDT 2015


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


More information about the systemd-devel mailing list