Skip to content

Instantly share code, notes, and snippets.

@jpuskar
Forked from sgnn7/haproxy_cluster_vars.conf
Created January 13, 2017 01:11
Show Gist options
  • Save jpuskar/00f0ab95a8b02d9e30691d89116426c1 to your computer and use it in GitHub Desktop.
Save jpuskar/00f0ab95a8b02d9e30691d89116426c1 to your computer and use it in GitHub Desktop.
Seamless haproxy on marathon-lb w/ systemd
# /etc/systemd/system/haproxy.service.d/haproxy_cluster_vars.conf
[Service]
Environment="PIDFILE=/run/haproxy.pid"
Environment="HAPROXY_SOCKET=/var/run/haproxy/socket"
# Get rid of the socket on start/stop
ExecStartPre=/bin/bash -c "rm -f $HAPROXY_SOCKET"
ExecStopPost=/bin/bash -c "rm -f $HAPROXY_SOCKET"
# XXX: Do seamless reloads
ExecReload=
ExecReload=/usr/sbin/haproxy -c -f ${CONFIG}
ExecReload=-/bin/bash -c 'echo > /var/state/haproxy/global && \
/usr/bin/socat /var/run/haproxy/socket - <<< "show servers state" > /var/state/haproxy/global'
ExecReload=/bin/kill -USR2 $MAINPID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment