Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reload are now working more stable

  • Loading branch information...
commit aa14a883db229fc62ad4281986ce9c4f884cfde3 1 parent a6ba67f
@jryberg authored
Showing with 53 additions and 13 deletions.
  1. +53 −13 daemon-init.in
View
66 daemon-init.in
@@ -25,13 +25,6 @@ if [ -e /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
-status() {
- [ ! -e $pidfile ] && return 1;
- PID=`cat $pidfile`;
- kill -0 $PID
- return $?
-}
-
prefix="@prefix@"
exec_prefix="@exec_prefix@"
exec="@bindir@/naemon"
@@ -50,6 +43,22 @@ test -e /etc/sysconfig/$prog && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
+status() {
+ [ ! -e $pidfile ] && return 1;
+ PID=`cat $pidfile`;
+ kill -0 $PID
+ return $?
+}
+
+pidof_naemon() {
+ if [ -e "$pidfile" ]; then
+ if pidof $prog | tr ' ' '\n' | grep -w $(cat $pidfile); then
+ return 0
+ fi
+ fi
+ return 1
+}
+
check_config() {
TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX)
$0 configtest > "$TMPFILE"
@@ -72,6 +81,32 @@ check_config() {
fi
}
+naemon_wait_stop() {
+ pidtmp=$(pidof_naemon) || true
+ if kill -0 "${pidtmp:-}" 2> /dev/null; then
+ pid=$pidtmp
+ fi
+ stop
+
+ # wait until really stopped
+ if [ -n "${pid:-}" ]; then
+ i=0
+ while kill -0 "${pid:-}" 2> /dev/null; do
+ if [ $i = '60' ]; then
+ break;
+ else
+ if [ $i = '0' ]; then
+ echo -n " ... waiting "
+ else
+ echo -n "."
+ fi
+ i=$(($i+1))
+ sleep 1
+ fi
+ done
+ fi
+}
+
start() {
test -x $exec || exit 5
test -f $config || exit 6
@@ -103,8 +138,12 @@ start() {
stop() {
echo -n "Stopping $prog: "
- pkill -u ${user} -f ${exec} || \
- pkill -u ${user} -f $(basename $exec) # ex.: sles uses basename only
+ pid=$(pidof_naemon) || true
+ if [ "${pid}" ]; then
+ kill $pid
+ else
+ return 1
+ fi
retval=$?
echo
test $retval -eq 0 && rm -f $lockfile
@@ -115,15 +154,16 @@ stop() {
restart() {
check_config
checkconfig="true"
- stop
- sleep 1
+ pid=$(pidof_naemon) || true
+ naemon_wait_stop
+ echo
start
}
reload() {
echo -n "Reloading $prog: "
pkill -HUP -u ${user} -f ${exec}
- RETVAL=$?
+ retval=$?
echo
}
@@ -173,7 +213,7 @@ case "$1" in
RETVAL=$?
;;
*)
- echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
+ echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
exit $?
Please sign in to comment.
Something went wrong with that request. Please try again.