Re: [PATCH] Add Upstart job configuration file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Fabio,

Thank you for restating. I updated the following files to be able to
choose installation of Job files than the last patch.
- configure.ac
- corosync.spec.in
- init/Makefile.am

----
 configure.ac                  |   15 +++++++++++
 corosync.spec.in              |   11 ++++++++-
 init/Makefile.am              |   11 ++++++--
 init/corosync-notifyd.conf.in |   38 ++++++++++++++++++++++++++++++
 init/corosync.conf.in         |   52
+++++++++++++++++++++++++++++++++++++++++
 5 files changed, 123 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1967a73..c32a2d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -342,6 +342,11 @@ AC_ARG_ENABLE([systemd],
 	[ enable_systemd="no" ])
 AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes)
 
+AC_ARG_ENABLE([upstart],
+	      [  --enable-upstart                : Install upstart service
files],,
+	[ enable_upstart="no" ])
+AM_CONDITIONAL(INSTALL_UPSTART, test x$enable_upstart = xyes)
+
 AC_ARG_WITH([initddir],
 	[  --with-initddir=DIR     : path to init script directory. ],
 	[ INITDDIR="$withval" ],
@@ -352,6 +357,11 @@ AC_ARG_WITH([systemddir],
 	[ SYSTEMDDIR="$withval" ],
 	[ SYSTEMDDIR="/lib/systemd/system" ])
 
+AC_ARG_WITH([upstartdir],
+	[  --with-upstartdir=DIR   : path to upstart config files directory.
],
+	[ UPSTARTDIR="$withval" ],
+	[ UPSTARTDIR="$sysconfdir/init" ])
+
 AC_ARG_WITH([initwrappersdir],
 	[  --with-initwrappersdir=DIR   : path to init wrappers files
directory. ],
 	[ INITWRAPPERSDIR="$withval" ],
@@ -431,6 +441,9 @@ fi
 if test "x${enable_systemd}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
 fi
+if test "x${enable_upstart}" = xyes; then
+	PACKAGE_FEATURES="$PACKAGE_FEATURES upstart"
+fi
 if test "x${enable_xmlconf}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES xmlconf"
 fi
@@ -618,6 +631,7 @@ LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS
-Wl,--as-needed $COVERA
 AC_SUBST([BASHPATH])
 AC_SUBST([INITDDIR])
 AC_SUBST([SYSTEMDDIR])
+AC_SUBST([UPSTARTDIR])
 INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR})
 AC_SUBST([INITWRAPPERSDIR])
 
@@ -660,6 +674,7 @@ AC_MSG_RESULT([  State information        =
${localstatedir}])
 AC_MSG_RESULT([  System configuration     = ${sysconfdir}])
 AC_MSG_RESULT([  System init.d directory  = ${INITDDIR}])
 AC_MSG_RESULT([  System systemd directory = ${SYSTEMDDIR}])
+AC_MSG_RESULT([  System upstart directory = ${UPSTARTDIR}])
 AC_MSG_RESULT([  System init wraps dir    = ${INITWRAPPERSDIR}])
 AC_MSG_RESULT([  corosync config dir      = ${COROSYSCONFDIR}])
 AC_MSG_RESULT([  Features                 =${PACKAGE_FEATURES}])
diff --git a/corosync.spec.in b/corosync.spec.in
index b262f2c..49374b1 100644
--- a/corosync.spec.in
+++ b/corosync.spec.in
@@ -12,6 +12,7 @@
 %bcond_with dbus
 %bcond_with rdma
 %bcond_with systemd
+%bcond_with upstart
 %bcond_with xmlconf
 %bcond_with runautogen
 
@@ -102,11 +103,15 @@ export rdmacm_LIBS=-lrdmacm \
 %if %{with systemd}
 	--enable-systemd \
 %endif
+%if %{with upstart}
+	--enable-upstart \
+%endif
 %if %{with xmlconf}
 	--enable-xmlconf \
 %endif
 	--with-initddir=%{_initrddir} \
-	--with-systemddir=%{_unitdir}
+	--with-systemddir=%{_unitdir} \
+	--with-upstartdir=%{_sysconfdir}/init
 
 make %{_smp_mflags}
 
@@ -197,6 +202,10 @@ fi
 %{_initrddir}/corosync
 %{_initrddir}/corosync-notifyd
 %endif
+%if %{with upstart}
+%{_sysconfdir}/init/corosync.conf
+%{_sysconfdir}/init/corosync-notifyd.conf
+%endif
 %dir %{_localstatedir}/lib/corosync
 %dir %{_localstatedir}/log/cluster
 %{_mandir}/man8/corosync_overview.8*
diff --git a/init/Makefile.am b/init/Makefile.am
index 804ad7c..18cf2bb 100644
--- a/init/Makefile.am
+++ b/init/Makefile.am
@@ -34,7 +34,7 @@
 
 MAINTAINERCLEANFILES	= Makefile.in
 
-EXTRA_DIST		= corosync.in corosync-notifyd.in
corosync.service.in corosync-notifyd.service.in
+EXTRA_DIST		= corosync.in corosync-notifyd.in
corosync.service.in corosync-notifyd.service.in corosync.conf.in
corosync-notifyd.conf.in
 
 if INSTALL_SYSTEMD
 systemdconfdir	   = $(SYSTEMDDIR)
@@ -45,6 +45,11 @@ initscriptdir	   = $(INITDDIR)
 endif
 initscript_SCRIPTS  = corosync corosync-notifyd
 
+if INSTALL_UPSTART
+upstartconfdir     = $(UPSTARTDIR)
+upstartconf_DATA   = corosync.conf corosync-notifyd.conf
+endif
+
 %: %.in Makefile
 	rm -f $@-t $@
 	cat $< | sed \
@@ -57,7 +62,7 @@ initscript_SCRIPTS  = corosync corosync-notifyd
 	    > $@-t
 	mv $@-t $@
 
-all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
+all-local: $(initscript_SCRIPTS) $(systemdconf_DATA) $(upstartconf_DATA)
 
 clean-local:
-	rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA)
+	rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA) $(upstartconf_DATA)
diff --git a/init/corosync-notifyd.conf.in b/init/corosync-notifyd.conf.in
new file mode 100644
index 0000000..b1ac70c
--- /dev/null
+++ b/init/corosync-notifyd.conf.in
@@ -0,0 +1,38 @@
+# corosync-notifyd - Corosync Dbus and snmp notifier
+#
+# Starts corosync-notifyd
+
+expect fork
+respawn
+
+env prog=corosync-notifyd
+env rpm_sysconf=@SYSCONFDIR@/sysconfig/corosync-notifyd
+env rpm_lockfile=@LOCALSTATEDIR@/lock/subsys/corosync-notifyd
+env deb_sysconf=@SYSCONFDIR@/default/corosync-notifyd
+env deb_lockfile=@LOCALSTATEDIR@/lock/corosync-notifyd
+
+script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    exec $prog $OPTIONS
+end script
+
+pre-start script
+    mkdir -p @LOCALSTATEDIR@/run
+end script
+
+post-start script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] &&
LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] &&
LOCK_FILE="$deb_lockfile"
+    touch $LOCK_FILE
+end script
+
+post-stop script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] &&
LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] &&
LOCK_FILE="$deb_lockfile"
+    rm -f $LOCK_FILE
+end script
diff --git a/init/corosync.conf.in b/init/corosync.conf.in
new file mode 100644
index 0000000..a0243f9
--- /dev/null
+++ b/init/corosync.conf.in
@@ -0,0 +1,52 @@
+# corosync - Corosync Cluster Engine
+#
+# Starts corosync
+
+expect fork
+
+env prog=corosync
+env rpm_sysconf=@SYSCONFDIR@/sysconfig/corosync
+env rpm_lockfile=@LOCALSTATEDIR@/lock/subsys/corosync
+env deb_sysconf=@SYSCONFDIR@/default/corosync
+env deb_lockfile=@LOCALSTATEDIR@/lock/corosync
+
+script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    exec $prog
+end script
+
+pre-start script
+    mkdir -p @LOCALSTATEDIR@/run
+end script
+
+post-start script
+wait_for_ipc()
+{
+    try=0
+    while [ "$try" -le "20" ]; do
+        if corosync-cfgtool -s > /dev/null 2>&1; then
+            return 0
+        fi
+        sleep 0.5
+        try=$((try + 1))
+    done
+    logger -i -t "$UPSTART_JOB" "ERROR: Any interfaces are faulty!"
+    return 1
+}
+    wait_for_ipc || { stop; exit 1; }
+
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] &&
LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] &&
LOCK_FILE="$deb_lockfile"
+    touch $LOCK_FILE
+end script
+
+post-stop script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] &&
LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] &&
LOCK_FILE="$deb_lockfile"
+    rm -f $LOCK_FILE
+end script
----
Best regards,
Kazunori INOUE


> -----Original Message-----
> From: discuss-bounces@xxxxxxxxxxxx [mailto:discuss-bounces@xxxxxxxxxxxx]
On
> Behalf Of Fabio M. Di Nitto
> Sent: Monday, March 18, 2013 6:24 PM
> To: discuss@xxxxxxxxxxxx
> Subject: Re:  [PATCH] Add Upstart job configuration file
> 
> Hi Kazunori,
> 
> On 3/18/2013 9:48 AM, Kazunori INOUE wrote:
> > Hi Fabio,
> >
> > I know that Upstart has been replaced by systemd, but I don't use
> > systemd because I'm using RHEL 6.
> > And nobody detects abnormal end of corosync-notifyd process started
> > by /etc/init.d/corosync-notifyd.
> >
> > So the main purpose that I use Upstart for is to respawn it when
> > corosync-notifyd process terminated abnormally.  Therefore I
> > specified "respawn" in job of notifyd.
> >
> > I made job "corosync" incidentally because I made job of notifyd :)
> 
> this is all fine I believe. By optional I meant the integration with the
> build system (Makefiles/configure), the same way systemd and sysvinit
> are made so that user can enable/disable upstream at ./configure time.
> 
> Cheers
> Fabio
> 
>

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux