Sfoglia il codice sorgente

Send corosync startup notification to systemd

This enables starting the daemon directly in the service file, because
dependent units won't be started until initialization is complete.

Signed-off-by: Ferenc Wágner <wferi@debian.org>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Ferenc Wágner 8 anni fa
parent
commit
09b0123d58
4 ha cambiato i file con 15 aggiunte e 5 eliminazioni
  1. 2 0
      configure.ac
  2. 2 2
      exec/Makefile.am
  3. 8 0
      exec/main.c
  4. 3 3
      init/corosync.service.in

+ 2 - 0
configure.ac

@@ -486,6 +486,8 @@ if test "x${enable_augeas}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES augeas"
 fi
 if test "x${enable_systemd}" = xyes; then
+	PKG_CHECK_MODULES([libsystemd], [libsystemd])
+	AC_DEFINE([HAVE_LIBSYSTEMD], [1], [have systemd interface library])
 	PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
 	WITH_LIST="$WITH_LIST --with systemd"
 fi

+ 2 - 2
exec/Makefile.am

@@ -68,10 +68,10 @@ endif
 
 corosync_CPPFLAGS	= -DLOGCONFIG_USE_ICMAP=1
 
-corosync_CFLAGS         = $(statgrab_CFLAGS)
+corosync_CFLAGS         = $(statgrab_CFLAGS) $(libsystemd_CFLAGS)
 
 corosync_LDADD		= libtotem_pg.la ../common_lib/libcorosync_common.la \
-			  $(LIBQB_LIBS) $(statgrab_LIBS)
+			  $(LIBQB_LIBS) $(statgrab_LIBS) $(libsystemd_LIBS)
 
 corosync_DEPENDENCIES	= libtotem_pg.la ../common_lib/libcorosync_common.la
 

+ 8 - 0
exec/main.c

@@ -96,6 +96,10 @@
 #include <semaphore.h>
 #include <string.h>
 
+#ifdef HAVE_LIBSYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
+
 #include <qb/qbdefs.h>
 #include <qb/qblog.h>
 #include <qb/qbloop.h>
@@ -292,6 +296,10 @@ static void corosync_sync_completed (void)
 	 * Inform totem to start using new message queue again
 	 */
 	totempg_trans_ack();
+
+#ifdef HAVE_LIBSYSTEMD
+	sd_notify (0, "READY=1");
+#endif
 }
 
 static int corosync_sync_callbacks_retrieve (

+ 3 - 3
init/corosync.service.in

@@ -6,9 +6,9 @@ Requires=network-online.target
 After=network-online.target
 
 [Service]
-ExecStart=@INITWRAPPERSDIR@/corosync start
-ExecStop=@INITWRAPPERSDIR@/corosync stop
-Type=forking
+EnvironmentFile=-@INITCONFIGDIR@/corosync
+ExecStart=@SBINDIR@/corosync -f $OPTIONS
+Type=notify
 
 # The following config is for corosync with enabled watchdog service.
 #