systemd: Is it wrong?

Adam Williamson awilliam at redhat.com
Tue Jul 12 00:29:38 UTC 2011


On Mon, 2011-07-11 at 13:34 -0400, Steve Dickson wrote:
> 
> On 07/11/2011 04:42 AM, Michal Schmidt wrote:
> > On Sun, 10 Jul 2011 20:49:56 -0400 Steve Dickson wrote:
> >> Ok.. Now understand where my confusion is... Currently when one
> >> want to start the nfs server they type 'service nfs start' which
> >> calls a number of binaries and ultimately a system daemon.
> > 
> > We could achieve something similar with systemd by providing a target
> > unit 'nfs.target'. The unit would pull the daemons using requirement
> > dependencies.
> > 
> >> Now if they enable want secure nfs, they edit a file in /etc/systconf
> >> and simply type 'service nfs restart' which again runs a number 
> >> of binaries and start a couple of system daemons.
> > 
> > This could be another target 'nfs-secure.target'. It would pull
> > 'nfs.target' + more daemons.
> > 
> > The users would start and enable these target units instead of
> > the units of the individual daemons.
> This definitely sounds promising... When you have some code to 
> play around please let me know... I'm more than willing to help
> out.. 

There's no 'code' involved, really, targets are a feature of systemd and
you create them much like services. Take a look
at /lib/systemd/system/graphical.target
and /lib/systemd/system/graphical.target.wants , for instance. All you
need is a definition for the target and the .wants subdirectory
containing symlinks to the services included in (in systemd terminology,
'wanted by') the target.

So if, in converting NFS to systemd, we wound up with five services
which all need to be run to start up NFS completely:

/lib/systemd/system/nfs-1.service
/lib/systemd/system/nfs-2.service
/lib/systemd/system/nfs-3.service
/lib/systemd/system/nfs-4.service
/lib/systemd/system/nfs-5.service

you'd just have a /lib/systemd/system/nfs.target with the normal boring
boilerplate:

[Unit]
Description=NFS
Requires=network.target

and a /lib/systemd/system/nfs.target.wants/ directory containing
symlinks to:

/lib/systemd/system/nfs-1.service
/lib/systemd/system/nfs-2.service
/lib/systemd/system/nfs-3.service
/lib/systemd/system/nfs-4.service
/lib/systemd/system/nfs-5.service

and Bob would be your uncle. More or less. I just did all that on the
back of an envelope and it's probably wrong somewhere. But you get the
idea.
-- 
Adam Williamson
Fedora QA Community Monkey
IRC: adamw
http://www.happyassassin.net



More information about the devel mailing list