Created
June 20, 2013 16:21
-
-
Save andrewconner/5824253 to your computer and use it in GitHub Desktop.
Killing a running Play! framework application. First gracefully, and then quite violently.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maxShutdownTime=15 | |
function stopServiceProcess { | |
kill $pid || return 1 | |
for ((i=0; i<maxShutdownTime*10; i++)); do | |
checkProcessIsRunning $pid | |
if [ $? -ne 0 ]; then | |
rm -f $pidFile | |
return 0 | |
fi | |
sleep 0.1 | |
done | |
echo -e "\n$serviceName did not terminate within $maxShutdownTime seconds, sending SIGKILL..." | |
kill -s KILL $pid || return 1 | |
local killWaitTime=15 | |
for ((i=0; i<killWaitTime*10; i++)); do | |
checkProcessIsRunning $pid | |
if [ $? -ne 0 ]; then | |
rm -f $pidFile | |
return 0 | |
fi | |
sleep 0.1 | |
done | |
echo "Error: $serviceName could not be stopped within $maxShutdownTime+$killWaitTime seconds!" | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment