Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (45 sloc) 1.3 KB
#!/bin/bash
# The logic to stop your application should be put in this script.
# debug
# set -x
#loads VERSION, DEPS_PARAMS, ID, LOG_FILE, PLAY_COMMAND="${OPENSHIFT_DATA_DIR}play-${VERSION}/play"
. ${OPENSHIFT_REPO_DIR}.openshift/action_hooks/load_config
if [[ ! $? -eq 0 ]]; then
exit $?
fi
RUNNING_PID=${OPENSHIFT_REPO_DIR}/RUNNING_PID
#kill play if it was running
if [[ -f $RUNNING_PID ]]; then
echo "Stopping play application"
kill `cat $OPENSHIFT_REPO_DIR/RUNNING_PID` && sleep 5;
bash -c "rm $OPENSHIFT_REPO_DIR/RUNNING_PID &> $LOG_FILE" &> /dev/null
fi
#it survived, try to kill it manually
if [[ -n `ps -A | grep ' java$'` ]]; then
# try 5 times to kill it
for c in `seq 1 5`; do
echo "Trying to kill java proccess, attemp number $c"
bash -c "pkill java &> $LOG_FILE" &> /dev/null
sleep $c
#killed it
if [[ -z `ps -A | grep ' java$'` ]]; then
exit 0
fi
done
# try 5 times to kill it
for c in `seq 1 5`; do
echo "Trying to kill java proccess with -SIGKILL, attemp number $c"
bash -c "pkill -SIGKILL java &> $LOG_FILE" &> /dev/null
sleep $c
#killed it
if [[ -z `ps -A | grep ' java$'` ]]; then
exit 0
fi
done
#couldn't kill it
if [[ -n `ps -A | grep ' java$'` ]]; then
echo "Error: could not stop play application, error executing 'pkill java'"
exit 1
fi
fi
exit 0