diff --git a/docker/haproxy/extend_start.sh b/docker/haproxy/extend_start.sh index 16a65c0afabd69f55e8a6bcf47fb13b1f5569a41..c33780d207723960a39c5a0f58edab5e6475ab16 100644 --- a/docker/haproxy/extend_start.sh +++ b/docker/haproxy/extend_start.sh @@ -7,11 +7,16 @@ sysctl net.unix.max_dgram_qlen=128 echo "Running command: '${CMD}'" $CMD -# TODO(SamYaple): This has the potential for a race condition triggered by a -# config reload that could cause the container to exit -while [[ -e "/proc/$(cat /run/haproxy.pid)" ]]; do +retry=0 +# The loop breaks only when haproxy.pid get missing even after 3 re-try. +while [[ $retry -lt 3 ]]; do + if [[ ! -e /run/haproxy.pid || ! -d /proc/$(cat /run/haproxy.pid) ]]; then + retry=$((retry+1)) + sleep 2 + continue + fi + retry=0 sleep 5 done -# Based on the above loop this point should never be reached exit 1