[systemd-devel] Best practices for starting unit only if network is online

Lennart Poettering lennart at poettering.net
Tue Mar 31 13:16:47 UTC 2020


On Mi, 05.02.20 13:23, Paul Menzel (pmenzel+systemd-devel at molgen.mpg.de) wrote:

> Dear systemd folks,
>
>
> fwupd ships the service unit `fwupd-refresh.service` with the ordering below
> [1].
>
>     After=network.target network-online.target systemd-networkd.service
> NetworkManager.service connman.service
>
> I would have thought ordering after `network-online.target` would be enough.
> Are there best practices for ensuring that the network is working?

Well, who knows what "online" means... fwupd should really start
independently of all of this and watch network state on its own and
retry whenever state changes. IIRC glib even has an API for it.

These targets should only really be used for stuff that really really
needs the network, and where it's intended the boot process shall be
delayed for, for example if you mount /var or so from NFS. And maybe
for naive shell scripts that can't be bothered to do things properly,
but fwupd doesn't qualify...

fwupd.target should not list the various network management solutions,
that is unnecssary, and ordering after network.target should be
sufficeint to achieve the same, in a generic fashion. i.e. network
managers should order themselves before network.target, so that
ordring yourself after that automatically orders you after all
implementations at once...

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list