[systemd-devel] Restarting dependant services after failure recovery

Iñigo Martínez inigomartinez at gmail.com
Sun Dec 27 07:49:02 PST 2015


Hello,

I have created 3 services (A, B, C) that must be started at boot, where the
first one, A, gathers some data from a custom web service and shares it
with the other two using D-Bus. Hence I have created the service files in
which B and C depend on A.

$ /etc/systemd/system/A.service
[Unit]
Description=A Service
Requires=local-fs.target network-online.target
Before=B.service C.service

[Service]
...
RestartSec=5
Restart=always

$ /etc/systemd/system/B.service
[Unit]
Description=B Service
Requires=A.service
After=A.service

[Service]
...
RestartSec=5
Restart=always

$ /etc/systemd/system/C.service
[Unit]
Description=C Service
Requires=A.service
After=A.service

[Service]
...
RestartSec=5
Restart=always

The problem is that the network isn't always available, which causes A to
fail at start, and therefore B and C fail too, with a "failed with result
'dependency'" status.

As Restart option is configured with always option, A finally restarts
later successfully, but not B and C, as they get stuck in the failed state
instead of restarting when A finally starts.

I have been looking for answers and I found this thread[0] (and the same
question here[1]) of july with the same problem but without any answer in
the end, so my question is:

Doesn't it make more sense to try to restart dependant services when the
service they depend on recovers/starts successfully if they have
Restart=always option?

Best regards,

[0]
http://lists.freedesktop.org/archives/systemd-devel/2015-July/033512.html
[1]
http://unix.stackexchange.com/questions/213185/restarting-systemd-service-on-dependency-failure
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151227/da2a0397/attachment.html>


More information about the systemd-devel mailing list