From: Jacek Konieczny <jajcus@jajcus.net>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/2] Startup notification by sd_notify()
Date: Sat, 3 Nov 2012 16:27:56 +0100 [thread overview]
Message-ID: <1351956476-4261-3-git-send-email-jajcus@jajcus.net> (raw)
In-Reply-To: <1351956476-4261-1-git-send-email-jajcus@jajcus.net>
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 <jajcus@jajcus.net>
---
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 <linux/genetlink.h>
#include <linux/dlm_netlink.h>
+#ifdef USE_SD_NOTIFY
+#include <systemd/sd-daemon.h>
+#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
next prev parent reply other threads:[~2012-11-03 15:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-03 15:27 [Cluster-devel] cluster4 dlm: startup notification for systemd Jacek Konieczny
2012-11-03 15:27 ` [Cluster-devel] [PATCH 1/2] --foreground option added to dlm_controld Jacek Konieczny
2012-11-03 15:27 ` Jacek Konieczny [this message]
2012-11-05 16:20 ` [Cluster-devel] cluster4 dlm: startup notification for systemd David Teigland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351956476-4261-3-git-send-email-jajcus@jajcus.net \
--to=jajcus@jajcus.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).