aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2015-09-11 10:35:20 +0200
committerLukas Nykryn <lnykryn@redhat.com>2015-09-15 13:08:05 +0200
commit4407d519f7866ba326eb5203514c8e547b162509 (patch)
tree0833459aba89cd93a382b07592425cb36df6f377
parentb7fe878e3ff4c53b1dee335e8d4164dbbd058198 (diff)
downloadinitscripts-4407d519f7866ba326eb5203514c8e547b162509.tar
initscripts-4407d519f7866ba326eb5203514c8e547b162509.tar.gz
initscripts-4407d519f7866ba326eb5203514c8e547b162509.tar.bz2
initscripts-4407d519f7866ba326eb5203514c8e547b162509.tar.xz
initscripts-4407d519f7866ba326eb5203514c8e547b162509.zip
service: improve status and stop function for daemon with intscripts
When daemon abnormally dies systemd leaves it in active state. This is due to support of initscripts like network. We can guess if it is a daemon or not.
-rw-r--r--rc.d/init.d/functions9
-rwxr-xr-xservice7
2 files changed, 15 insertions, 1 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index f7d3ca93..430ac388 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -387,7 +387,14 @@ status() {
if [ "$_use_systemctl" = "1" ]; then
systemctl status ${0##*/}.service
- return $?
+ ret=$?
+ # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
+ # lets adjust the reality a little bit
+ if systemctl show -p ActiveState ${0##*/}.service | grep -q '=active$' && \
+ systemctl show -p SubState ${0##*/}.service | grep -q '=exited$' ; then
+ ret=3
+ fi
+ return $ret
fi
# First try "pidof"
diff --git a/service b/service
index c8bf0a2b..79792fc5 100755
--- a/service
+++ b/service
@@ -71,6 +71,13 @@ while [ $# -gt 0 ]; do
done
if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
+ # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
+ # lets reap them before next start
+ if [ "${ACTION}" = "start" ] && \
+ systemctl show -p ActiveState ${SERVICE}.service | grep -q '=active$' && \
+ systemctl show -p SubState ${SERVICE}.service | grep -q '=exited$' ; then
+ /bin/systemctl stop ${SERVICE}.service
+ fi
env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
elif [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" -a -n "${ACTION}" ]; then
env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS}