[systemd-devel] networking services management idea

Ferron, Chris E chris.e.ferron at intel.com
Wed Aug 1 17:01:56 PDT 2012


Hello,

      I have been working on an idea utilizing systemd to solve a
problem on a couple of projects I am working on. The basic problem is
how to manage services requiring not only networking but also
networking in a specific state (or even being useful only during a
specific state). For the most part networking service have been
trained by now to handle when networking is available or not, but why
have such service running when networking is not available. Also when
to start a service, some (not all) services could be started only when
they would be useful, ie when the networking state they need|should
have is available for example. In my case its simple, I have devices
where startup time and power are very important, and I have a set of
networking services that don’t really need to be started until the
networking state is such where they useful. I also have interest of
not having service running if there is no networking. My case this is
relatively small, but this may have a more expandable use overall with
the right input. I do not want to manage the networking sessions, just
when and how the services are managed.

 As I looked into solving this problem, systemd seemed to be a good
starting point. I have systemd and its really good at managing
service. So my solution (prototyped) was to use systemd units to start
| stop services based on the current state of the network. Starting
simply, I supply two target units network-(ready|online).target. The
two generic target organized two basic states. READY meaning the
network was connected (local) and ONLINE meaning the network was
connected (external). I then subscribe to notifications (in my
prototype using connman) state changes, and make dbus calls to systemd
to start and stop the target units based on network state. The again
states are "READY" and "ONLINE" now but could be expanded to say idle
for example.  At this point the code is not interesting part, but the
idea is somewhat at least to me.

With my prototype I can now place services such as updaters, sshd,
dns, “MY PERSONL SERVICE” in an appropriate target, and let systemd
manage them, but also insure they are started in sync with wanted
network state. Now my updater service won’t start until I have
external connectivity for example. I also can better control from my
needs (or say a distro’s needs etc) when networking service start, so
they all don’t start at the same time.

Right now my prototype is external to both the network manager and
systemd, relying on dbus and such. But I started thinking that this
might be a decent overall idea, and with a little input might be of
interest to more then just my projects. My worst-case scenario is no
one is interested, but I get some interesting feedback and a little
food for thought as I harden a solution to my problem. Best case is
there is interested and I use the feedback to extend current direction
to be more useful to all.



Thanks in advanced for your time.

-Chris


More information about the systemd-devel mailing list