Просмотр исходного кода

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 лет назад
Родитель
Сommit
09b0123d58
4 измененных файлов с 15 добавлено и 5 удалено
  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"
 	PACKAGE_FEATURES="$PACKAGE_FEATURES augeas"
 fi
 fi
 if test "x${enable_systemd}" = xyes; then
 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"
 	PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
 	WITH_LIST="$WITH_LIST --with systemd"
 	WITH_LIST="$WITH_LIST --with systemd"
 fi
 fi

+ 2 - 2
exec/Makefile.am

@@ -68,10 +68,10 @@ endif
 
 
 corosync_CPPFLAGS	= -DLOGCONFIG_USE_ICMAP=1
 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 \
 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
 corosync_DEPENDENCIES	= libtotem_pg.la ../common_lib/libcorosync_common.la
 
 

+ 8 - 0
exec/main.c

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

+ 3 - 3
init/corosync.service.in

@@ -6,9 +6,9 @@ Requires=network-online.target
 After=network-online.target
 After=network-online.target
 
 
 [Service]
 [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.
 # The following config is for corosync with enabled watchdog service.
 #
 #