From 55f2d49e25fe7182414fccb3573df28d12d98720 Mon Sep 17 00:00:00 2001 From: bandesz Date: Tue, 28 Feb 2017 17:38:18 +0000 Subject: [PATCH] Add termination timeout to run_app_paas.sh --- scripts/run_app_paas.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/run_app_paas.sh b/scripts/run_app_paas.sh index e892ef010..f00ed5a70 100755 --- a/scripts/run_app_paas.sh +++ b/scripts/run_app_paas.sh @@ -2,6 +2,8 @@ set -e -o pipefail +TERMINATE_TIMEOUT=30 + function check_params { if [ -z "${NOTIFY_APP_NAME}" ]; then echo "You must set NOTIFY_APP_NAME" @@ -38,11 +40,18 @@ EOF function on_exit { echo "Terminating application process with pid ${APP_PID}" kill ${APP_PID} || true + n=0 while (kill -0 ${APP_PID} 2&>/dev/null); do echo "Application is still running.." sleep 1 + let n=n+1 + if [ "$n" -ge "$TERMINATE_TIMEOUT" ]; then + echo "Timeout reached, killing process with pid ${APP_PID}" + kill -9 ${APP_PID} || true + break + fi done - echo "Application process exited, waiting 10 seconds" + echo "Application process terminated, waiting 10 seconds" sleep 10 echo "Terminating remaining subprocesses.." kill 0