loki
loki copied to clipboard
After=network.target should be After=network-online.target
In all your service files, After=network.target should be After=network-online.target.
Failure to do so will lead to flaky, unpredictable behaviour.
See man systemd.special, it says of network.target that:
This unit is supposed to indicate when network functionality is available, but it is only very weakly defined
And the rest of the man-page section about network.target basically appears to imply you should only rely on it during the shutdown process, not during boot.
Meanwhile the man systemd.special on network-online.target is pretty clear, e.g. :
Units that strictly require a configured network connection should pull in network-online.target (via a Wants= type dependency) and order themselves after it.
Thanks for pointing this out @udf2457
https://systemd.io/NETWORK_ONLINE/ even suggests to use
After=network-online.target
Wants=network-online.target
@chaudum Regarding the suggestion, indeed.
After= is simply ordering, Wants= provides the actual hard-dependency.
So best practice in situations such as network-online is indeed to have both, because you actually want the actual hard-dependency for obvious reasons. :wink: