From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacek Konieczny Date: Sat, 3 Nov 2012 16:27:56 +0100 Subject: [Cluster-devel] [PATCH 2/2] Startup notification by sd_notify() In-Reply-To: <1351956476-4261-1-git-send-email-jajcus@jajcus.net> References: <1351956476-4261-1-git-send-email-jajcus@jajcus.net> Message-ID: <1351956476-4261-3-git-send-email-jajcus@jajcus.net> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Implements simple start-up status notification via the sd_notify(3) function from the libsystemd-daemon library. This allows proper service startup serialization by the init daemon ? services depending on DLM will be started after dlm_controld completes the initialization. As this pulls additional dependency, the feature my by disabled on compile time by calling 'make' with 'USE_SD_NOTIFY=no'. Signed-off-by: Jacek Konieczny --- dlm_controld/Makefile | 8 ++++++++ dlm_controld/main.c | 8 ++++++++ init/dlm.service | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile index f42a913..13d6339 100644 --- a/dlm_controld/Makefile +++ b/dlm_controld/Makefile @@ -6,6 +6,8 @@ LIBDIR=$(PREFIX)/$(LIBNUM) HDRDIR=$(PREFIX)/include MANDIR=$(PREFIX)/share/man +USE_SD_NOTIFY=yes + BIN_TARGET = dlm_controld LIB_NAME = libdlmcontrol @@ -59,6 +61,12 @@ BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum LIB_CFLAGS += $(BIN_CFLAGS) LIB_LDFLAGS += -Wl,-z,relro -pie +ifeq ($(USE_SD_NOTIFY),yes) + BIN_CFLAGS += $(shell pkg-config --cflags libsystemd-daemon) \ + -DUSE_SD_NOTIFY + BIN_LDFLAGS += $(shell pkg-config --libs libsystemd-daemon) +endif + all: $(LIB_TARGET) $(BIN_TARGET) $(BIN_TARGET): $(BIN_SOURCE) diff --git a/dlm_controld/main.c b/dlm_controld/main.c index deda60c..d1fdb2a 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -14,6 +14,10 @@ #include #include +#ifdef USE_SD_NOTIFY +#include +#endif + #include "copyright.cf" #include "version.cf" @@ -1012,6 +1016,10 @@ static void loop(void) plock_fd = rv; plock_ci = client_add(rv, process_plocks, NULL); +#ifdef USE_SD_NOTIFY + sd_notify(0, "READY=1"); +#endif + for (;;) { rv = poll(pollfd, client_maxi + 1, poll_timeout); if (rv == -1 && errno == EINTR) { diff --git a/init/dlm.service b/init/dlm.service index 3c4e53e..f068c63 100644 --- a/init/dlm.service +++ b/init/dlm.service @@ -3,10 +3,11 @@ Description=dlm control daemon After=syslog.target network.target corosync.service sys-kernel-config.mount [Service] -Type=forking +Type=notify +NotifyAccess=main EnvironmentFile=/etc/sysconfig/dlm ExecStartPre=/sbin/modprobe dlm -ExecStart=/usr/sbin/dlm_controld $DLM_CONTROLD_OPTS +ExecStart=/usr/sbin/dlm_controld --foreground $DLM_CONTROLD_OPTS #ExecStopPost=/sbin/modprobe -r dlm [Install] -- 1.7.7.4