mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-28 07:59:02 +01:00
SERVER-9253 fixed init.d/mongod so that it does not sleep for 5 minutes unnecessarily.
In some version of Linux, killproc() provided in /etc/init.d/functions has a bug where it will sleep the full duration of the delay (-d). Closes #411 Signed-off-by: Benety Goh <benety@mongodb.com>
This commit is contained in:
parent
8f9c2e19ae
commit
fb1e82a243
33
rpm/init.d-mongod
Normal file → Executable file
33
rpm/init.d-mongod
Normal file → Executable file
@ -72,7 +72,7 @@ start()
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping mongod: "
|
||||
killproc -p "$PIDFILEPATH" -d 300 /usr/bin/mongod
|
||||
mongo_killproc $mongod
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
|
||||
@ -83,6 +83,37 @@ restart () {
|
||||
start
|
||||
}
|
||||
|
||||
# Send TERM signal to process and wait up to 300 seconds for process to go away.
|
||||
# If process is still alive after 300 seconds, send KILL signal.
|
||||
# Built-in killproc() (found in /etc/init.d/functions) is on certain versions of Linux
|
||||
# where it sleeps for the full $delay seconds if process does not respond fast enough to
|
||||
# the initial TERM signal.
|
||||
mongo_killproc()
|
||||
{
|
||||
local procname=$1
|
||||
local -i delay=300
|
||||
local -i duration=10
|
||||
local pid=`pidofproc -p "$PIDFILEPATH" $procname`
|
||||
|
||||
kill -TERM $pid >/dev/null 2>&1
|
||||
usleep 100000
|
||||
local -i x=0
|
||||
while [ $x -le $delay ] && checkpid $pid; do
|
||||
sleep $duration
|
||||
x=$(( $x + $duration))
|
||||
done
|
||||
|
||||
kill -KILL $pid >/dev/null 2>&1
|
||||
usleep 100000
|
||||
|
||||
rm -f "$PIDFILEPATH"
|
||||
|
||||
checkpid $pid
|
||||
local RC=$?
|
||||
[ "$RC" -eq 0 ] && failure "${procname} shutdown" || success "${procname} shutdown"
|
||||
RC=$((! $RC))
|
||||
return $RC
|
||||
}
|
||||
|
||||
RETVAL=0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user