systemd: add kdnotify.service, kdnotify.socket

As we expect this project to be mostly run as a system service, provide
out of the box configuration files for systemd.

Notably, we add a .socket file allowing systemd to lazily start kdnotify
when a notify event is received on its socket.

We also hardlink the socket out into the /run/ directory, such that
keepalived does not need to peak inside kdnotify runtime dir.

We also link the lifecycle of kdnotify to keepalived, as once it has
been stopped it is unlikely we'll receive new messages.
This commit is contained in:
Paul Stemmet 2022-12-10 19:01:35 +00:00
parent d9ff2c6477
commit dc343acf44
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
3 changed files with 27 additions and 3 deletions

4
.gitignore vendored
View File

@ -15,7 +15,5 @@
!*.sh !*.sh
!*.yaml !*.yaml
!systemd/*
!*/ !*/
src/
pkg/

16
systemd/kdnotify.service Normal file
View File

@ -0,0 +1,16 @@
[Unit]
Description=Keepalived notify handler
Documentation=https://git.st8l.com/luxolus/kdnotify
Before=keepalived.service
StopPropagatedFrom=keepalived.service
JoinsNamespaceOf=keepalived.service
[Service]
RuntimeDirectory=kdnotify
ConfigurationDirectory=kdnotify
EnvironmentFile=-/etc/default/kdnotify
ExecStart=/bin/kdnotify watch $EXTRAOPTS ${RUNTIME_DIRECTORY}/notify.fifo
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target

10
systemd/kdnotify.socket Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=kdnotify FIFO socket
Documentation=https://git.st8l.com/luxolus/kdnotify
[Socket]
ListenFIFO=/run/kdnotify/notify.fifo
ExecStartPost=/bin/ln -f /run/kdnotify/notify.fifo /run/kdnotify.fifo
[Install]
WantedBy=sockets.target