mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-10-04 10:03:38 +00:00
init: major cleanup
- rename generic.in and notifyd.in to corosync.in and corosync-notifyd.in (makes build simpler) - fix sysvinit corosync.in sleep time to include a check for when IPC are ready and drop cman bits (there is no cman with corosync 2.0) - corosync-notifyd.service should always start after corosync.service - corosync.service should always start after network - corosync.service uses init script wrapper - install/ship sysvinit as wrappers for systemd in /usr/share/corosync when necessary - change the build system to deal with all of the above Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com> Reviewed-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
parent
0791f44c41
commit
d7e205d197
1
TODO
1
TODO
@ -17,7 +17,6 @@
|
||||
* porting of qdisk to votequorum and eventually finalize qdevice API
|
||||
in votequorum. (Fabio)
|
||||
* Cleaner shutdown process -> free memory (Fabio)
|
||||
* Merge init and systemd stuff (Fabio)
|
||||
|
||||
--------------------------------------
|
||||
Current priority list for Needle 2.X
|
||||
|
@ -290,6 +290,11 @@ AC_ARG_WITH([systemddir],
|
||||
[ SYSTEMDDIR="$withval" ],
|
||||
[ SYSTEMDDIR="/lib/systemd/system" ])
|
||||
|
||||
AC_ARG_WITH([initwrappersdir],
|
||||
[ --with-initwrappersdir=DIR : path to init wrappers files directory. ],
|
||||
[ INITWRAPPERSDIR="$withval" ],
|
||||
[ INITWRAPPERSDIR="$datarootdir/corosync" ])
|
||||
|
||||
AC_ARG_ENABLE([snmp],
|
||||
[ --enable-snmp : SNMP protocol support ],
|
||||
[ default="no" ])
|
||||
@ -585,6 +590,8 @@ LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS"
|
||||
# substitute what we need:
|
||||
AC_SUBST([INITDDIR])
|
||||
AC_SUBST([SYSTEMDDIR])
|
||||
INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR})
|
||||
AC_SUBST([INITWRAPPERSDIR])
|
||||
|
||||
AC_SUBST([SOMAJOR])
|
||||
AC_SUBST([SOMINOR])
|
||||
@ -631,6 +638,8 @@ AC_MSG_RESULT([ Arch-independent files = ${datadir}])
|
||||
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 init wraps dir = ${INITWRAPPERSDIR}])
|
||||
AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}])
|
||||
AC_MSG_RESULT([ Features =${PACKAGE_FEATURES}])
|
||||
AC_MSG_RESULT([])
|
||||
|
@ -169,6 +169,9 @@ fi
|
||||
%if %{with systemd}
|
||||
%{_unitdir}/corosync.service
|
||||
%{_unitdir}/corosync-notifyd.service
|
||||
%dir %{_datadir}/corosync
|
||||
%{_datadir}/corosync/corosync
|
||||
%{_datadir}/corosync/corosync-notifyd
|
||||
%else
|
||||
%{_initrddir}/corosync
|
||||
%{_initrddir}/corosync-notifyd
|
||||
|
@ -34,38 +34,30 @@
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
EXTRA_DIST = generic.in notifyd.in corosync.service.in corosync-notifyd.service.in
|
||||
EXTRA_DIST = corosync.in corosync-notifyd.in corosync.service.in corosync-notifyd.service.in
|
||||
|
||||
if INSTALL_SYSTEMD
|
||||
systemdconfdir = $(SYSTEMDDIR)
|
||||
systemdconf_DATA = corosync.service corosync-notifyd.service
|
||||
systemdconfdir = $(SYSTEMDDIR)
|
||||
systemdconf_DATA = corosync.service corosync-notifyd.service
|
||||
initscriptdir = $(INITWRAPPERSDIR)
|
||||
else
|
||||
target_INIT = generic notifyd
|
||||
initscriptdir = $(INITDDIR)
|
||||
endif
|
||||
initscript_SCRIPTS = corosync corosync-notifyd
|
||||
|
||||
%: %.in Makefile
|
||||
rm -f $@-t $@
|
||||
sed \
|
||||
cp $< $@-t
|
||||
sed -i \
|
||||
-e 's#@''SBINDIR@#$(sbindir)#g' \
|
||||
-e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
|
||||
-e 's#@''INITDDIR@#$(INITDDIR)#g' \
|
||||
-e 's#@''INITWRAPPERSDIR@#$(INITWRAPPERSDIR)#g' \
|
||||
-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
|
||||
$< > $@-t
|
||||
$@-t
|
||||
mv $@-t $@
|
||||
|
||||
all-local: $(target_INIT) $(systemdconf_DATA)
|
||||
all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
|
||||
|
||||
clean-local:
|
||||
rm -rf $(target_INIT) $(systemdconf_DATA)
|
||||
|
||||
if INSTALL_SYSTEMD
|
||||
else
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)/$(INITDDIR)
|
||||
$(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync
|
||||
$(INSTALL) -m 755 notifyd $(DESTDIR)/$(INITDDIR)/corosync-notifyd
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)/$(INITDDIR) && \
|
||||
rm -f corosync corosync-notifyd
|
||||
endif
|
||||
rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA)
|
||||
|
@ -1,6 +1,7 @@
|
||||
[Unit]
|
||||
Description=Corosync Dbus and snmp notifier
|
||||
Wants=corosync.service
|
||||
After=corosync.service
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=@SYSCONFIGDIR@/corosync-notifyd
|
||||
|
@ -81,6 +81,20 @@ cluster_disabled_at_boot()
|
||||
return 0
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n "Starting $desc ($prog): "
|
||||
@ -98,40 +112,20 @@ start()
|
||||
else
|
||||
$prog > /dev/null 2>&1
|
||||
|
||||
# give it time to fail
|
||||
sleep 2
|
||||
if status $prog > /dev/null 2>&1; then
|
||||
touch $LOCK_FILE
|
||||
success
|
||||
else
|
||||
if ! wait_for_ipc; then
|
||||
failure
|
||||
rtrn=1
|
||||
fi
|
||||
touch $LOCK_FILE
|
||||
success
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
executed_by_cman()
|
||||
{
|
||||
[ -f @LOCALSTATEDIR@/run/cman.pid ] || return 0
|
||||
|
||||
read cman_pid foo < @LOCALSTATEDIR@/run/cman.pid
|
||||
if [ "$(pidof $prog)" == "$cman_pid" ];then
|
||||
echo -n "$desc was executed by cman"
|
||||
failure
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
! status $prog > /dev/null 2>&1 && return
|
||||
|
||||
! executed_by_cman && return
|
||||
|
||||
echo -n "Signaling $desc ($prog) to terminate: "
|
||||
kill -TERM $(pidof $prog) > /dev/null 2>&1
|
||||
success
|
@ -1,12 +1,13 @@
|
||||
[Unit]
|
||||
Description=Corosync Cluster Engine
|
||||
ConditionKernelCommandLine=!nocluster
|
||||
#Conflicts=cman.service
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@SBINDIR@/corosync
|
||||
ExecStart=@INITWRAPPERSDIR@/corosync start
|
||||
ExecStop=@INITWRAPPERSDIR@/corosync stop
|
||||
Type=forking
|
||||
#RestartSec=90s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user