On Tue, Dec 22, 2020 at 1:36 PM Ronald Wimmer <[email protected]> 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
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to