HAProxy community

Restart HAProxy with Puppet managed installation

Hi,
I am managing my HAProxy configurations through Puppet module and it seems that when there is a modification it sends a Notify[Service] which turns into “systemctl restart haproxy”. I am not sure why they don’t do reload instead… However I need to dump the status of the servers before restarting it, let’s say I have 1 node in drain, after the restart without saving the state this node will come back online.
Any suggestion ? Is it safe to do restart when changing a configuration?

Here is the systemd file in case someon can help:

[Unit]
Description=HAProxy Load Balancer
After=network.target

[Service]
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid"
EnvironmentFile=-/etc/sysconfig/haproxy
ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q
ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $OPTIONS
ExecReload=/usr/sbin/haproxy -f $CONFIG -c -q
ExecReload=/etc/haproxy/server-state/update-servers-status.sh
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Type=notify

[Install]
WantedBy=multi-user.target

You need to configure server-state-file pointing to the file and adjust the system unit to dump the state to that file: