Created
August 23, 2022 15:47
-
-
Save wiedehopf/33841e36de69a318d8874e1d6b98d5ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
function mainpid() { | |
systemctl show --property MainPID haproxy | cut -d= -f2 | |
} | |
while sleep 0.15; do | |
OLDPID=$(mainpid) | |
echo "Stopping haproxy" | |
kill "$OLDPID" || true | |
while true; do | |
sleep 0.15 | |
PID=$(mainpid) | |
if (( PID != OLDPID || PID == 0 )); then | |
break | |
else | |
echo "waiting" | |
fi | |
done | |
while ! systemctl is-active --quiet haproxy; do | |
echo "Starting haproxy" | |
systemctl start haproxy || true | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment