Stopping and Restarting HAProxy

HAProxy supports a graceful and a hard stop.

  • The hard stop occurs when the SIGTERM signal is sent to the haproxy process, it immediately quits and all established connections are closed. The hard stop method is used for the “stop” or “restart” actions of the service management script.
  • The graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process. It consists in only unbinding from listening ports, but continue to process existing connections until they close. Once the last connection is closed, the process leaves. The graceful stop is used for the “reload” action which tries to seamlessly reload a new configuration in a new process.

Both of these signals may be sent by the new haproxy process itself during a reload or restart, so that they are sent at the latest possible moment and only if absolutely required.

You do this with the “-st” (hard) and “-sf” (graceful) options respectively.

Restarting in master-worker mode

In master-worker mode, it is not necessary to start a new HAProxy process in order to reload the configuration. The master process reacts to the SIGUSR2 signal by re-executing itself with the -sf parameter followed by the PIDs of the workers. The master will then parse the configuration file and reload new workers automatically.