Restarting Haproxy Gracefully
- by Anand Gupta
As per various blogs, HAproxy can be gracefully restarted using the following command:
sudo haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)
TO verify this, I had set up a apache bench script which contiguously sent message to haproxy. Ideally, whenever I restarted my server the script should not have an affect on the apache bunch execiton. But, it seems that whenever Haproxy is restarted apache bench scripts terminate and the connection to load balancer is lost.
Here is the details of my HaProxy configuration file :
global
nbproc 4
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
pidfile /var/run/haproxy.pid
stats socket /home/ubuntu/haproxy.sock
#debug
#quiet
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen webstats
bind 0.0.0.0:1000
stats enable
mode http
stats uri /lb?stats
stats auth anand:aaaaaaaa
#stats refresh
listen web-farm 0.0.0.0:80
mode http
balance roundrobin
option httpchk HEAD /index.php HTTP/1.0
server server2.com 1.1.1.1:80
server serve1.com 1.1.1.2:80
~
Please let me know what am I missing here.