From 5d3469c7b8ba4854f7dcb96bc1745a9ba3d1e035 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 29 Oct 2015 19:56:27 +0000
Subject: [PATCH] fixed while loop not exiting

loop did not exit if graceful shutdown failed. 30 wait time
---
 functions/fn_stop | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/fn_stop b/functions/fn_stop
index 2270914eb..c5c36c2b3 100644
--- a/functions/fn_stop
+++ b/functions/fn_stop
@@ -128,7 +128,7 @@ else
             fn_scriptlog "Attempting graceful shutdown"
             tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
             counter=0
-            while [ "${pid}" != "0" ]; do
+            while [ "${pid}" != "0" -a $counter -lt 30 ]; do
                 pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
                 sleep 1
                 let counter=counter+1