[systemd-devel] network consuming user services

Lennart Poettering lennart at poettering.net
Wed May 2 15:29:04 PDT 2012


On Wed, 02.05.12 22:19, Sebastian Tramp (mail at sebastian.tramp.name) wrote:

> Hi,
> 
> I want to start some user services which need a working network connection.
> This includes services as
> 
> * "fetchmail --idle" to receive mails
> * ssh tunnel with autossh
> * dyndns update
> 
> I recently switched to systemd 44 on arch linux but after one day of try and
> error as well as manpage reading I am not sure that this is in the scope of
> systemd.
> 
> The best solution could be to hear on dbus, if the NetworkManager sends an
> "online event". The services need to be finished if the network is down and
> started again if we are online again.
> 
> Are there existing service files which solve a similar or the same
> issue?

Ideally services like yours would just listen to netlink events so that
they can properly handle connectivity coming and going. In today's
dynamic world having daemons that fail if the network isn't up is
backwards, in particular since the definition of "network is up" is
hard on machines with multiple network interfaces, or machines connected
indirectly to the internet. i.e. link beat or pingability might matter
more.

In summary: we think the only correct way to handle network connectivity
is to make the daemons watch netlink. To provide compatibility with
services that currently not do it we provide the generic
"network.target" which can be used as synchronization point for all
services that only care for "network is up", for whatever definition
this might be. Depending on the specific installation this can then be
filled with different definitions. One option for example is to enable
the "NetworkManager-wait-online.service", which hooks into NM and waits
until a network configuration is applied and is subject to a
timeout. Just run "systemctl enable NetworkManager-wait-online.service"
and it will order itself before network.target, thus exposing the
desired behaviour.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list