-
-
Save keontang/133a029af96e9cbaedf1534094d07a75 to your computer and use it in GitHub Desktop.
Upstart script for haproxy with support for reload.
This file contains 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
description "Properly handle haproxy" | |
start on startup | |
env PID_PATH=/var/run/haproxy.pid | |
env BIN_PATH=/usr/sbin/haproxy | |
script | |
exec /bin/bash <<EOF | |
$BIN_PATH -f /etc/haproxy.cfg -D -p $PID_PATH | |
trap "$BIN_PATH -f /etc/haproxy.cfg -p $PID_PATH -sf \\\$(cat $PID_PATH)" SIGHUP | |
trap "kill -TERM \\\$(cat $PID_PATH) && exit 0" SIGTERM SIGINT | |
while true; do # Iterate to keep job running. | |
sleep 1 # Don't sleep to long as signals will not be handled during sleep. | |
done | |
EOF | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment