[systemd-devel] Special targets - should they Want or be WantedBy?

Mike Kazantsev mk.fraggod at gmail.com
Thu Mar 17 07:10:06 PDT 2011


On Thu, 17 Mar 2011 14:32:26 +0300
Andrey Borzenkov <arvidjaar at mail.ru> wrote:

> On Thu, Mar 17, 2011 at 1:59 PM, Mike Kazantsev <mk.fraggod at gmail.com> wrote:
> > On Thu, 17 Mar 2011 12:41:34 +0300
> > Andrey Borzenkov <arvidjaar at mail.ru> wrote:
> >
> >> On Thu, Mar 17, 2011 at 11:06 AM, Mike Kazantsev <mk.fraggod at gmail.com> wrote:
> >> > On Thu, 17 Mar 2011 01:04:35 +0100
> >> > Lennart Poettering <lennart at poettering.net> wrote:
> >> >> If DefaultDependencies= is "yes" (which it is by default) for target
> >> >> units then they'll automatically gain an After= for all untis they have
> >> >> Wants= or Requires= on.
> >>
> >> > Can this behavior be relied upon or this might change in future
> >> > releases?
> >> >
> >> > It's just that this magic bit makes After= line in lots of units I've
> >> > seen (and wrote) redundant, so can it be dropped and skipped in any
> >> > new units or it's better to be explicit in this case?
> >> >
> >>
> >> Do you have that many target units?
> >
> > Ah, I missed the "target units" part, but even then
> > "Requires=network.target + After=network.target" is a common
> > enough pattern for services that need network to be up at startup and
> > After= line is present in each one of them:
> >
> 
> Dependencies are added to target for units that it pulls. Not other way round.
> 

Hm, indeed, I should've read that statement much more carefully.

> >  /lib/systemd/system/noip.service:Requires=network.target
> >  /lib/systemd/system/dnscache.service:Requires=network.target
> >  /lib/systemd/system/tinydns.service:Requires=network.target
> >  /lib/systemd/system/remote-fs.target:Requires=network.target
> >  /lib/systemd/system/ziproxy.service:Requires=network.target
> >  /lib/systemd/system/ejabberd.service:Requires=network.target
> >  /lib/systemd/system/dhcpd.service:Requires=network.target
> 
> I tentatively think that these should be either After or Requisite. Do
> you really want to start network every time one of those services gets
> started (assuming there were reasons to have network stopped at this
> moment)?

Since they can't function without network (usually failing if interface
doesn't exists), pulling in network as a dependency seem to be sensible
thing to do, no point to start dependencies manually.

Disabling the network in such configuration can be done by masking
network.target, either via symlink to /dev/null or
systemd.blacklist_units= parameter.

After+Requisite seem to be an alternative, although enabling service
and it's dependencies explicitly for it not to fail looks
counter-intuitive to me - services usually pull in needed deps without
requiring you to enable whole pyramid of them below, constantly failing
on any missing piece.


-- 
Mike Kazantsev // fraggod.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20110317/7e7d7b76/attachment-0001.pgp>


More information about the systemd-devel mailing list