[systemd-devel] how to properly control the daemons or run advanced cmds

Lennart Poettering lennart at poettering.net
Sun Nov 30 15:52:50 PST 2014


On Tue, 25.11.14 00:09, Flavio Leitner (fbl at redhat.com) wrote:

> 
> Hello,
> 
> The Open vSwitch is comprised by two daemons. One is a database and
> another is the switch itself.
> 
> Currently we have the openvswitch.service which start/stop/reload the
> service (both daemons) just fine.

In general we strongly recommend to expose daemons 1:1 as systemd
services. systemd is all about keeping track of daemons, and it does
those by watching the main process of them. If you now stick many
daemons in the same systemd service then you make the whole excercise
moot. This is not only missing the point of systemd, but also makes
the whole system much less transparent for admins.

> However, we need to support hot-upgrade which means to stop the
> vswitch daemon first, run a few special commands, reload the db
> daemon and only then start the vswitch daemon.
> 
> I know about creating shell helpers for non-standard commands, but
> since that needs to mess up with the daemons in a particular order,
> I think systemd won't like the above external actions at all.
> 
> Any suggestion on how to handle this with systemd properly?

My recommendation would be something like this:

a) make it two units

b) assuming the switch daemon is client to the db daemon, add deps 
   to the switch daemon for After= and Requires= on the db daemon.

c) Add the "special commands" to the ExecStartPre= of the db daemon,
   and make them idempotent so that they can run any time, even if the
   package is already upgraded (in which case thy should to degrade to
   NOPs...)

Now, on upgrades just do "systemctl restart" for the db daemon. This
should stop the switch daemon first, the stop the db daemon, then
start the db daemon again (executing the ExecStartPre= first), then
start the switch again.

Hope that makes sense?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list