[systemd-devel] /etc/systemd/system/darkice.service

Lennart Poettering lennart at poettering.net
Thu Jul 25 13:17:41 PDT 2013

On Mon, 22.07.13 17:48, Kai Hendry (hendry at iki.fi) wrote:

> On 19 July 2013 01:29, Lennart Poettering <lennart at poettering.net> wrote:
> > It is certainly surprising at first, but it makes a lot of sense. In
> > systemd ordering deps and requirement deps are truly orthogonal. This is
> > useful in many cases, because sometimes you just want to pull something
> > else in, but not imply any ordering, sometimes you want to order without
> > actually pulling it in, and often you want to do both. Of course, not
> > all deps make sense in all combinations, but I think it's easy enough to
> > grasp.
> What happens in the range of error cases when a user puts a Wants=
> line under the (wrong) [Install] heading?

We generally generate warnings about invalid lines and proceed. Aftre we
parsed everything we then do a couple of checks whether a unit still
makes sense with the stuff that was correctly parsed, and only if the
unit does't pass that check we will fail it.

> I tried it and network-online.target was loaded inactive dead, so it
> failed IIUC. No warning that Wants= line is in the wrong place. This
> sucks quite a lot imo.

"loaded inactive dead" does not indicate any error, just that the thing
didn't get started.

> I enabled the above as pingtest.service and added
> Wants=network-online.target under the [Unit] heading in
> darkice.service.
> Still I don't understand how pingtest.service can fail here with exit
> 2 and even more confusingly network-online.target is reached!?
> http://ix.io/6Nv

Does it work if you run it from the command line?

WantedBy= means that a unit is pulled in but it is not relevant whether
it succeed to reach a target. There's also RequiredBy= which is the
stronger option where that does matter. Generally, for robustness
reasons we suggest people to use "WantedBy" rather than "RequiredBy",
but it's up to you.

> > This will timeout after 60 seconds.
> Isn't this better "controlled" by systemd itself? And not be a command
> line switch in the exec?

We currently don't support Timeouts on type=oneshot services, but we
should fix it.

> > It's hacky, generates awful traffic, and has quite some latency, but it
> > should do what you asked for...
> Awful traffic? One successful ping and we continue IIUC.

Well, you still bombard the local network if the internet connection is
sewered far away... This doesn't really scale to more than a few sysem.

> A lot of routers IIUC do a heart beat type ping to ensure it's up. And
> if not it would switch to another route or something. If routers are
> doing this, why can't my device? Is it really that expensive??

They usually use exponentially increasing intervals, to avoid flooding.


Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list