Here are the current network hooks used in Bitcoin Core systemd integration template:
Semantically, it makes sense, so I never questioned those lines when deploying new nodes, but here are some quotes from the official systemd website:
https://systemd.io/NETWORK_ONLINE/
$network / network-online.target is a mechanism that is required only to deal with software that assumes continuous network is available (i.e. of the simple not-well-written kind)
Services using the network should hence simply place an After=network.target stanza in their unit files, without Wants=network.target or Requires=network.target
After=network.target can be sure that it is stopped before the network is shut down when the system is going down. This allows services to cleanly terminate connections before going down, instead of losing ongoing connections leaving the other side in an undefined state.
If you are a developer, instead of wondering what to do about network.target, please just fix your program to be friendly to dynamically changing network configuration.
Watch rtnetlink and react to network configuration changes as they happen. This is usually the nicest solution, but not always the easiest.
It looks like the use of network-online.target
is discouraged and network.target
is a preferred option for any program which knows how to adapt to changing network conditions. Are there any good reasons not to follow the official recommendation?