Hi all,

after digging a bit into the Fedora/RH bug tracker I suggest the
improved version for the keepalived.service unit in the attached patch.
This version is slightly adapted from:
> http://pkgs.fedoraproject.org/cgit/keepalived.git/tree/keepalived.service

Some explanations:

The changes to debian/rules and debian/control are just what is
recommended on the Debian wiki [1] and the examples linked there.

Now about the keepalived.service options:

> [Unit]
> After=syslog.target network-online.target
> Wants=network-online.target

Keepalived would like to use logging and usable networking, see Fedora
bug #1181097 [2]. I don't think Keepalived will start without working
network, so I have added it to Wanted. I have no idea, why this was
dropped from the bug report.

> # Only start if there is a configuration file
> ConditionFileNotEmpty=/etc/keepalived/keepalived.conf
Just like the Debian init script.

> [Service]
> Type=forking
> KillMode=process
from [3]:
By default, keepalived running in VRRP mode starts 2 processes.
When systemd uses its default stop method (cgroup), it kills
both of these processes, and this does not allow keepalived to
perform any required cleanup (such as removing VRRP IPs).  On stop,
only the main process should receive a kill signal

> # Read configuration variable file if it is present
> EnvironmentFile=-/etc/default/keepalived
> ExecStart=/usr/sbin/keepalived $DAEMON_ARGS
Just like the Debian init script, and as recommended on [1]

> ExecReload=/bin/kill -HUP $MAINPID
from [3]:
Reloading keepalived is useful in cases where you want to remove
a VRRP IP, or add a new VRRP IP without removing existing IPs.

> [Install]
> WantedBy=multi-user.target
That's what everybody does. Just like the old runlevel 2 or 3.


Please let me know if I can do anything else to help.

Robert.


[1] https://wiki.debian.org/systemd/Packaging
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1181097
[3] https://bugzilla.redhat.com/show_bug.cgi?id=769726
diff --git a/debian/control b/debian/control
index 1b7210f..ce5a0e3 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Priority: extra
 Maintainer: Alexander Wirt <formo...@debian.org>
 Build-Depends: autoconf,
                debhelper (>= 9),
+               dh-systemd (>= 1.3),
                libnl-3-dev,
                libnl-genl-3-dev,
                libpopt-dev,
diff --git a/debian/keepalived.service b/debian/keepalived.service
new file mode 100644
index 0000000..8e507d4
--- /dev/null
+++ b/debian/keepalived.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Keepalive Daemon (LVS and VRRP)
+After=syslog.target network-online.target
+Wants=network-online.target
+# Only start if there is a configuration file
+ConditionFileNotEmpty=/etc/keepalived/keepalived.conf
+
+[Service]
+Type=forking
+KillMode=process
+# Read configuration variable file if it is present
+EnvironmentFile=-/etc/default/keepalived
+ExecStart=/usr/sbin/keepalived $DAEMON_ARGS
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/rules b/debian/rules
index 1c50c13..66d075b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,7 @@
 #export DH_OPTIONS=-v
 
 %:
-	dh  $@ --with autoreconf
+	dh  $@ --with autoreconf --with=systemd
 
 override_dh_auto_configure:
 	dh_auto_configure -- --with-kernel-dir=debian/  --enable-snmp --enable-sha1

Reply via email to