[systemd-devel] SystemD dependency problem

Mantas Mikulėnas grawity at gmail.com
Tue Dec 22 13:17:29 UTC 2020


On Tue, Dec 22, 2020 at 1:36 PM Ronald Wimmer <ronaldw at ronzo.at> wrote:

> On a server running OL 7.9 with SystemD 219 we have a custom SystemD
> service we have something like
>
>
> [Unit]
> Requires=network.target docker.service
>
> [Service]
> Restart=always
> RestartSec=10
> TimeoutSec=300
> WorkingDirectory=/data/someapplication
> ExecStartPre=<pull a docker image>
> ExecStart=<docker-compose up>
> ExecStop=<docker-compose stop>
> ExecStopPost=<docker-compose down>
>
> [Install]
> WantedBy=network-online.target
>
> which does not work. This service leads do several other services
> (rsyslogd, docker, network-online.target, ...) to be stuck in "start
> waiting".
>
> My question is why? Is there any obvious misconfiguration in the service
> above I am too blind to see?
>

As a special case, when a target has Wants= for some unit, it will
automatically add an After= as well. (So from your unit's point of view,
you have [Install] WantedBy=network-online.target, so you can imagine that
you automatically have a Before=network-online.target as well – unless you
explicitly specify the opposite.)

However, Docker has "After=network-online.target", so you end up creating
an ordering loop:

* yourthing.service has no After=, but it runs `docker` commands and cannot
finish until docker.service is up;
* docker.service explicitly has After=network-online.target and won't start
until that target is reached;
* but network-online.target has an implicit After=yourthing.service (as
explained above).

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20201222/71553f32/attachment.htm>


More information about the systemd-devel mailing list