Konubinix' opinionated web of thoughts

Haproxy

Fleeting

reload the configuration

docker run --entrypoint /bin/cat haproxy:2.8.3 cat /usr/local/bin/docker-entrypoint.sh
#!/bin/sh
set -e

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
	set -- haproxy "$@"
fi

if [ "$1" = 'haproxy' ]; then
	shift # "haproxy"
	# if the user wants "haproxy", let's add a couple useful flags
	#   -W  -- "master-worker mode" (similar to the old "haproxy-systemd-wrapper"; allows for reload via "SIGUSR2")
	#   -db -- disables background mode
	set -- haproxy -W -db "$@"
fi

exec "$@"

Reloading config

If you used a bind mount for the config and have edited your haproxy.cfg file, you can use HAProxy’s graceful reload feature by sending a SIGHUP to the container:

$ docker kill -s HUP my-running-haproxy

The entrypoint script in the image checks for running the command haproxy and replaces it with haproxy-systemd-wrapper from HAProxy upstream which takes care of signal handling to do the graceful reload. Under the hood this uses the -sf option of haproxy so “there are two small windows of a few milliseconds each where it is possible that a few connection failures will be noticed during high loads” (see Stopping and restarting HAProxy).

https://hub.docker.com/_/haproxy

Notes linking here