Skip to content

Instantly share code, notes, and snippets.

@ezhuk
Last active January 6, 2024 04:19
Show Gist options
  • Save ezhuk/6480290 to your computer and use it in GitHub Desktop.
Save ezhuk/6480290 to your computer and use it in GitHub Desktop.
Reload HAProxy configuration with no downtime.
#!/bin/bash
#
# The trick here is to dump pids of all haproxy processes into a file
# (-p option) and then tell them to finish their work and exit (-sf).
HAPROXY=/usr/sbin/haproxy
HAPROXY_PID=/var/run/haproxy.pid
HAPROXY_CONFIG=/etc/haproxy/haproxy.cfg
$HAPROXY -f $HAPROXY_CONFIG -p $HAPROXY_PID -sf $(cat $HAPROXY_PID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment