Skip to content

Instantly share code, notes, and snippets.

@sgnn7
Created June 15, 2016 14:19
Show Gist options
  • Save sgnn7/c530c389c94a7a23f4f00f8f073fca78 to your computer and use it in GitHub Desktop.
Save sgnn7/c530c389c94a7a23f4f00f8f073fca78 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