forked from I2P_Developers/i2p.i2p
* Router shutdown:
- Fix failsafe shutdown hook broken in 0.8.8;
HUP, INT, and TERM signals should now shut down cleanly.
- Shutdown hook no longer prevents other hooks from running
- Trap HUP, if router.gracefulHUP=true, and do graceful shutdown.
Only under wrapper, non-Windows.
- i2prouter stop now uses SIGTERM
- Implement i2prouter graceful using SIGHUP (ticket #580)
- Configure wrapper to ignore SIGUSR1 and SIGUSR2 as they will shut down
or crash the JVM
This commit is contained in:
@@ -1012,6 +1012,7 @@ start() {
|
||||
startwait
|
||||
}
|
||||
|
||||
|
||||
stopit() {
|
||||
# $1 exit if down flag
|
||||
|
||||
@@ -1028,7 +1029,7 @@ stopit() {
|
||||
if [ "X$IGNORE_SIGNALS" = "X" ]
|
||||
then
|
||||
# Running so try to stop it.
|
||||
kill $pid
|
||||
kill -TERM $pid
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# An explanation for the failure should have been given
|
||||
@@ -1080,6 +1081,43 @@ stopit() {
|
||||
fi
|
||||
}
|
||||
|
||||
graceful() {
|
||||
# $1 exit if down flag
|
||||
|
||||
eval echo `gettext 'Stopping $APP_LONG_NAME gracefully...'`
|
||||
getpid
|
||||
if [ "X$pid" = "X" ]
|
||||
then
|
||||
eval echo `gettext '$APP_LONG_NAME was not running.'`
|
||||
if [ "X$1" = "X1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "X$IGNORE_SIGNALS" = "X" ]
|
||||
then
|
||||
# Running so try to stop it.
|
||||
# This sends HUP. router.gracefulHUP must be set in router.config,
|
||||
# or else this will do the same as stop.
|
||||
kill $pid
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# An explanation for the failure should have been given
|
||||
eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
rm -f "$ANCHORFILE"
|
||||
if [ -f "$ANCHORFILE" ]
|
||||
then
|
||||
# An explanation for the failure should have been given
|
||||
eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
pause() {
|
||||
eval echo `gettext 'Pausing $APP_LONG_NAME.'`
|
||||
}
|
||||
@@ -1557,6 +1595,7 @@ showUsage() {
|
||||
echo "`gettext ' console Launch in the current console.'`"
|
||||
echo "`gettext ' start Start in the background as a daemon process.'`"
|
||||
echo "`gettext ' stop Stop if running as a daemon or in another console.'`"
|
||||
echo "`gettext ' graceful Stop gracefully, may take up to 11 minutes.'`"
|
||||
echo "`gettext ' restart Stop if running and then start.'`"
|
||||
echo "`gettext ' condrestart Restart only if already running.'`"
|
||||
if [ -n "$PAUSABLE" ] ; then
|
||||
@@ -1624,6 +1663,11 @@ docommand() {
|
||||
stopit "0"
|
||||
;;
|
||||
|
||||
'graceful')
|
||||
checkUser "" "$COMMAND"
|
||||
graceful "0"
|
||||
;;
|
||||
|
||||
'restart')
|
||||
checkUser touchlock "$COMMAND"
|
||||
if [ ! -n "$FIXED_COMMAND" ] ; then
|
||||
|
||||
@@ -168,6 +168,10 @@ wrapper.logfile.maxfiles=2
|
||||
# Log Level for sys/event log output. (See docs for log levels)
|
||||
wrapper.syslog.loglevel=NONE
|
||||
|
||||
# these will shut down or crash the JVM
|
||||
wrapper.signal.mode.usr1=IGNORE
|
||||
wrapper.signal.mode.usr2=IGNORE
|
||||
|
||||
# choose what to do if the JVM kills itself based on the exit code
|
||||
wrapper.on_exit.default=SHUTDOWN
|
||||
wrapper.on_exit.0=SHUTDOWN
|
||||
|
||||
Reference in New Issue
Block a user