From 78f8ca7fcbe38d16538acf7f47cc152b8ef20103 Mon Sep 17 00:00:00 2001 From: acaranta Date: Sun, 25 Apr 2021 12:19:31 +0200 Subject: [PATCH] Added pgrep install Changed method to test if haproxy is running Forced pid override at loop start --- Dockerfile | 2 +- inotifreload.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 95366e7..b70695b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive ENV INITRD No RUN apt-get update -y -RUN apt-get install --force-yes -y haproxy inotify-tools python-pip curl lua-socket lua-json lua-http rsync +RUN apt-get install --force-yes -y haproxy inotify-tools python-pip curl lua-socket lua-json lua-http rsync pcregrep RUN pip install envtpl supervisor supervisor-logging #Fetch and build haproxy from github, compile it with prometheus exporter diff --git a/inotifreload.sh b/inotifreload.sh index afc2ebd..efd2aea 100755 --- a/inotifreload.sh +++ b/inotifreload.sh @@ -8,9 +8,15 @@ echo "$(date) - Starting inotify loop" while true; do RELOAD=0 #Check if haproxy is still running - if ! kill -0 $(cat /run/haproxy.pid) ; then - haproxy -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/$HASVC -D -p /run/haproxy.pid +# if ! kill -0 $(cat /run/haproxy.pid) ; then +# haproxy -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/$HASVC -D -p /run/haproxy.pid +# fi + if ! pgrep haproxy ; then + haproxy -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/$HASVC -D -p /run/haproxy.pid + else + pgrep haproxy >/run/haproxy.pid fi + #start an inotifywait (timeout -s <#> seconds) # inotifywait -t 10 -q -e close_write,moved_to,create /hacfg/$HASVC 2>&1 >/dev/null if [ -d /hacfg/certs ]; then