From f9f74785abb1d7090b802b73da1efec86972af72 Mon Sep 17 00:00:00 2001 From: Joao Morais Date: Sat, 9 Jan 2021 16:33:26 -0300 Subject: [PATCH] fix reload failure if admin socket refuses connection The reload script uses the admin socket to read the current haproxy state, before reloading a new configuration. This state reading would fail the reload if the socket exists but is refusing connection, eg if haproxy has died. --- rootfs/haproxy-reload.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rootfs/haproxy-reload.sh b/rootfs/haproxy-reload.sh index 3ee5cb9d9..9c427c680 100755 --- a/rootfs/haproxy-reload.sh +++ b/rootfs/haproxy-reload.sh @@ -37,8 +37,9 @@ set -e HAPROXY_SOCKET=/var/run/haproxy/admin.sock HAPROXY_STATE=/var/lib/haproxy/state-global if [ -S $HAPROXY_SOCKET ]; then - echo "show servers state" | socat $HAPROXY_SOCKET - > $HAPROXY_STATE -else + echo "show servers state" | socat $HAPROXY_SOCKET - > /tmp/state && mv /tmp/state $HAPROXY_STATE +fi +if [ ! -s $HAPROXY_STATE ]; then echo "#" > $HAPROXY_STATE fi case "$1" in