From e4936e4b807fa2359b2273e66b07b3734f130e4d Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 18 May 2015 12:05:47 -0400 Subject: [PATCH] Fix supervisor restart behavior for ubuntu, and adjust timeouts *way* down on when supervisor can harikiri it's child processes --- tools/scripts/ansible-tower | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/scripts/ansible-tower b/tools/scripts/ansible-tower index 3e3eb86991..1d48843184 100755 --- a/tools/scripts/ansible-tower +++ b/tools/scripts/ansible-tower @@ -35,8 +35,24 @@ service_action() { fi # Allow supervisor time to cleanup child pids (ubuntu only) if [[ ${svc} == supervisor* && ${1} == stop && -e /etc/debian_version ]]; then - echo "Waiting to allow supervisor time to cleanup ..." - sleep 5 + S_PID=$(pidof -x supervisord) + echo "Waiting to allow supervisor time to cleanup ... pid ${S_PID}" + if [ "${S_PID}" ]; then + i=0 + while kill -0 "${S_PID}" 2> /dev/null; do + if [ $i = '60' ]; then + break; + else + if [ $i == '0' ]; then + echo -n " ... waiting" + else + echo -n "." + fi + i=$(($i+1)) + sleep 1 + fi + done + fi fi done }