Skip to content

Instantly share code, notes, and snippets.

@obervinov
Created June 11, 2025 16:31
Show Gist options
  • Save obervinov/0cb76fd303953f8c7f2d81f4030b9300 to your computer and use it in GitHub Desktop.
Save obervinov/0cb76fd303953f8c7f2d81f4030b9300 to your computer and use it in GitHub Desktop.
Systemd for haproxy
# /etc/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=network.target
[Service]
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/var/run/haproxy.pid"
ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q
ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE -d
ExecReload=/usr/sbin/haproxy -f $CONFIG -c -q
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always
SuccessExitStatus=143
Type=notify
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment