Adding systemd unit files in OpenStack packages

Thomas Goirand zigo at debian.org
Sun Jul 6 14:33:35 BST 2014


Hi,

I've had a look here:
https://wiki.debian.org/systemd/Packaging

and didn't find the information that I'm looking for. I have a number of
question which I need to find answer for, then I'll be able to apply it
to all the packages and daemon (which is: A LOT).

I also prefer to ask for advice, because I don't want to repeat the same
mistake over and over again on all packages, which would be a huge time
waster. Sorry if the information is available somewhere and I missed it.
I also suppose that you prefer that I ask, and implement support for
systemd, rather than just do nothing and keep lame, old, init.d scripts! :)

Let's take an example with keystone. Currently, there's the following
init.d sysv-rc script LSB header:

# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      mysql postgresql slapd rabbitmq-server ntp
# Should-Stop:       mysql postgresql slapd rabbitmq-server ntp

How does this translate into a systemd unit? Especially, it'd be nice to
have mysql socket activation, but the service may be remote, so it
shouldn't be forced, but just be there if mysqld is local.

Then another example. With nova-compute, I have the following:

[ -r /etc/default/openstack ] && . /etc/default/openstack
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

[ "x$USE_SYSLOG" = "xyes" ] && DAEMON_ARGS="$DAEMON_ARGS --use-syslog"
[ "x$USE_LOGFILE" != "xno" ] && DAEMON_ARGS="$DAEMON_ARGS \
	--log-file /var/log/nova/$NAME.log"

The idea is that, by default, nova-compute only logs to a file. That is,
unless someone configures /etc/default/nova-compute. It is also possible
configure it globally in /etc/default/openstack (with the same
directives). How do I do this in a systemd unit file?

The daemon currently are started with start-stop-daemon. I do:

NAME=nova-compute
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="--config-file=/etc/nova/nova.conf"
PIDFILE=/var/run/$NAME.pid

[...]

do_start() {
        start-stop-daemon --start --background --quiet --chuid \
		${NOVA_USER}:nova --make-pidfile --pidfile $PIDFILE \
		--startas $DAEMON --test > /dev/null \
                || return 1

As per above, the daemon doesn't fork by itself. Should I also do a PID
file with systemd, or is there a better way, with supervision? How do I
do the restart on crash? Is there a way to send an email to root upon
crash of the daemon, or is this still not implemented in systemd? If it
isn't implemented, how can I tell systemd to leave that job of starting
and restarting the daemon to let's say monit?

How do I implement waiting for libvirtd socket, so that compute starts
after that?

I hope that's not too many questions. :)

Cheers,

Thomas Goirand (zigo)



More information about the Pkg-systemd-maintainers mailing list