Andy
Andy

Reputation: 11

How to disable server in runtime in haproxy when nbproc >1

We are using haproxy in Multiprocess environment (nbproc 20). We want to disable some server on fly from haproxy without restarting. We can easily do this with below command when nbproc = 1

echo "disable server Backend/ServerName" | socat stdio /var/run/haproxy/haproxy.sock 

How we can do same when nbproc > 1.

Upvotes: 1

Views: 956

Answers (1)

Esteban Fonseca
Esteban Fonseca

Reputation: 11

You need to create separate sockets for each nbproc

stats socket /var/run/haproxy.1.stats mode 600 level admin process 1
stats socket /var/run/haproxy.2.stats mode 600 level admin process 2
stats socket /var/run/haproxy.3.stats mode 600 level admin process 3

and then redirect your socat/nc commands to all the /var/run/haproxy.*.stats with a for loop or the way it best suits you like

for socket in /var/run/haproxy*.stats; do echo "set server <FARM NAME>/<HOST NAME> stat maint" | socat stdio $socket done

Same applies if you want ipv4@ sockets.

cheers!!

Upvotes: 1

Related Questions