Haproxy graceful reload

haproxyload balancing

I was looking for a solution for graceful reload of haproxy. I have a nginx server running which passes requests to Haproxy and at times I reload the Haproxy configuration. But I am observing that at time of reloading all the existing connections are getting cut off and haproxy backend queue shows 0 requests ( got from socket stats of haproxy ) .

I am using the method mentioned in several blog posts and haproxy documentation about the issue :

Reload :

haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -D -sf (</var/run/haproxy.pid)

Start :

haproxy -D  -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid 

It be grateful if someone could suggest any solution. Below is my haproxy config file

global
  maxconn 64000
  ulimit-n 200000
  log             127.0.0.1       local0
  log             127.0.0.1       local1 notice
  spread-checks 5
  stats socket /etc/haproxy/stats

defaults
  log global
  mode http
  balance roundrobin
  maxconn 64000
  option abortonclose
  option httpclose
  retries 3
  option redispatch
  timeout client 30000
  timeout connect 30000
  timeout server 30000
  stats enable
  stats uri     /haproxy?stats
  stats realm   Haproxy Statistics
  stats auth    haproxy:stats
  timeout check 5000

Best Answer

The command you posted does not seem 100% correct to me. On my system, it reads:

haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -D -sf $(cat /var/run/haproxy.pid)

You mistyped the value of last option -sf.