master - lvmlockd: improve systemd service file
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=297f6d51228d0f0d5debca9e95785f3623e0ef9d Commit: 297f6d51228d0f0d5debca9e95785f3623e0ef9d Parent: 1365f0d4c8f977cd3e426708891ee8d39ffe6527 Author: David Teigland <[email protected]> AuthorDate: Thu Sep 13 09:52:39 2018 -0500 Committer: David Teigland <[email protected]> CommitterDate: Thu Sep 13 09:52:39 2018 -0500
lvmlockd: improve systemd service file
use notify type so the daemon is ready
immediately after start.
--- daemons/lvmlockd/Makefile.in | 8 ++++++++ daemons/lvmlockd/lvmlockd-core.c | 8 ++++++++ scripts/lvm2_lvmlockd_systemd_red_hat.service.in | 9 +++------ 3 files changed, 19 insertions(+), 6 deletions(-)
daemons/lvmlockd/Makefile.in +8 -0
@@ -15,6 +15,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +USE_SD_NOTIFY=yes + SOURCES = lvmlockd-core.c ifeq ("@BUILD_LOCKDSANLOCK@", "yes")
@@ -40,6 +42,12 @@ INCLUDES += -I$(top_srcdir)/libdaemon/server LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) LIBS += $(RT_LIBS) $(DAEMON_LIBS) $(PTHREAD_LIBS) + +ifeq ($(USE_SD_NOTIFY),yes) + CFLAGS += $(shell pkg-config --cflags libsystemd) -DUSE_SD_NOTIFY + LDFLAGS += $(shell pkg-config --libs libsystemd) +endif + lvmlockd: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \ $(top_builddir)/libdaemon/server/libdaemonserver.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LOCK_LIBS) -ldaemonserver $(INTERNAL_LIBS) $(LIBS)
daemons/lvmlockd/lvmlockd-core.c +8 -0
@@ -35,6 +35,10 @@#include <sys/utsname.h> #include <sys/un.h> +#ifdef USE_SD_NOTIFY +#include <systemd/sd-daemon.h> +#endif +#define EXTERN #include "lvmlockd-internal.h"
@@ -5786,6 +5790,10 @@ static int main_loop(daemon_state *ds_arg)setup_worker_thread ();setup_restart (); +#ifdef USE_SD_NOTIFY +sd_notify (0 ,"READY=1" ); +#endif +/* * Attempt to rejoin lockspaces and adopt locks from a previous * instance of lvmlockd that left behind lockspaces/locks.
scripts/lvm2_lvmlockd_systemd_red_hat.service.in +3 -6
@@ -1,13 +1,10 @@ [Unit] -Description=LVM2 lock daemon +Description=LVM lock daemon Documentation=man:lvmlockd(8) -After=lvm2-lvmetad.service [Service] -Type=simple -NonBlocking=true -ExecStart=@SBINDIR@/lvmlockd -f -Environment=SD_ACTIVATION=1 +Type=notify +ExecStart=@SBINDIR@/lvmlockd --foreground PIDFile=@LVMLOCKD_PIDFILE@ SendSIGKILL=no