Make traditional init script fail if new config file is broken
Instead of assuming that upgrade is always successful, check if a new process actually started. Do not kill old process if the new one failed.
This commit is contained in:
parent
b7fd0fdd96
commit
4a5d1b6708
|
@ -83,19 +83,6 @@ do_stop()
|
||||||
return "$RETVAL"
|
return "$RETVAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Function that sends a SIGHUP to the daemon/service
|
|
||||||
#
|
|
||||||
do_reload() {
|
|
||||||
#
|
|
||||||
# If the daemon can reload its configuration without
|
|
||||||
# restarting (for example, when it is sent a SIGHUP),
|
|
||||||
# then implement that here.
|
|
||||||
#
|
|
||||||
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||||
|
@ -114,34 +101,38 @@ case "$1" in
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||||
;;
|
;;
|
||||||
upgrade)
|
upgrade)
|
||||||
log_daemon_msg "Upgrade $DESC" "$NAME"
|
log_daemon_msg "Upgrading $DESC" "$NAME"
|
||||||
pid=`pidofproc -p $PIDFILE $NAME`
|
oldpid=`pidofproc -p $PIDFILE $NAME`
|
||||||
case "$?" in
|
case "$?" in
|
||||||
0) echo "Sending USR2 signal to $pid"
|
0)
|
||||||
kill -USR2 $pid
|
log_progress_msg "Sending SIGUSR2 to $oldpid..."
|
||||||
echo "Waiting for new binary..."
|
kill -USR2 $oldpid
|
||||||
sleep 5
|
log_progress_msg "Waiting for new binary..."
|
||||||
echo "Sending QUIT signal to $pid"
|
for i in 1 2 3 4 5 ; do
|
||||||
kill -QUIT $pid
|
sleep 1
|
||||||
log_end_msg 0
|
newpid=`pidofproc -p $PIDFILE $NAME`
|
||||||
;;
|
if [ "$newpid" != "$oldpid" ] ; then
|
||||||
*) echo "pidofproc() failed"
|
break
|
||||||
log_end_msg 1
|
fi
|
||||||
;;
|
done
|
||||||
esac
|
if [ "$newpid" != "$oldpid" ] ; then
|
||||||
;;
|
log_progress_msg "Sending SIGQUIT to $oldpid..."
|
||||||
#reload|force-reload)
|
kill -QUIT $oldpid
|
||||||
#
|
log_end_msg 0
|
||||||
# If do_reload() is not implemented then leave this commented out
|
else
|
||||||
# and leave 'force-reload' as an alias for 'restart'.
|
log_progress_msg "New binary failed to start"
|
||||||
#
|
log_end_msg 1
|
||||||
#log_daemon_msg "Reloading $DESC" "$NAME"
|
fi
|
||||||
#do_reload
|
;;
|
||||||
#log_end_msg $?
|
*)
|
||||||
#;;
|
log_progress_msg "pidofproc() failed"
|
||||||
|
log_end_msg 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
#
|
#
|
||||||
# If the "reload" option is implemented then remove the
|
# If the "reload" option is implemented then remove the
|
||||||
|
|
Loading…
Reference in New Issue