systemd: Is it wrong?
mzerqung at 0pointer.de
Tue Jul 12 01:13:25 UTC 2011
On Mon, 11.07.11 17:16, Adam Williamson (awilliam at redhat.com) wrote:
> On Mon, 2011-07-11 at 18:18 +0200, Lennart Poettering wrote:
> > > One command that starts multiple process/daemons of a particular service.
> > > It as simple as that.
> > I guess we have to agree to disagree on this. A lost chance for NFS,
> Well, two people have already pointed out it's perfectly possible to
> achieve this even for the multiple service case by using a target.
You don't really need targets for this really. A target is a nice
abstraction that can be used to mean a lot of different things based on
configuration. But I think in the NFS case this isn't even necessary.
So what I am proposing is this. Split up the daemons, so that you have
one unit file per daemon. Have the main NFS daemon unit file pull in all
other required NFS deaemons via BindTo and backwards too to
ensure that they ara always started/stopped together. The optional
additional daemons hook in via nfs.service.wants/ links, via the usual
[Install] in them section and "systemctl enable".
Note that you can hook services into any other unit via .wants/ links
(including .service units!), not just into .target units. Nothing stops
you from placing "WantedBy=nfs.service" in a unit file, in fact I
encourage you to.
Or in other words: using a target is not the solution, but simply using
the relatively powerful set of dependencies you can express in systemd
Here's an example. let's say we have three nfs related services. The
main daemon is in nfs.service, an auxiliary service always needed by it
is nfs-mount.service, and a third service nfs-quota.service is
optional. Then write this:
Description=Main NFS Service
Description=Auxilary but mandatory NFS service
Description=Optional quota service for NFS
Then if you run "systemctl enable nfs.service" the first two services
will be started at next boot. If either one of them goes down the other
one will too. If you on top of that run "systemctl enable
nfs-quota.service", then this one will be started at boot too. If it
goes down the other ones don't care, but if you start nfs.service all
three will be started. Which is a pretty good behaviour.
Of course, these service names are all made up, but I believe the actual
existing NFS services are not unlike these three examples.
Lennart Poettering - Red Hat, Inc.
More information about the devel