Skip to content

Instantly share code, notes, and snippets.

@parsibox
Created September 2, 2025 11:32
Show Gist options
  • Save parsibox/2434d120a4d347ea63a23c8f99bc33b5 to your computer and use it in GitHub Desktop.
Save parsibox/2434d120a4d347ea63a23c8f99bc33b5 to your computer and use it in GitHub Desktop.

Revisions

  1. parsibox created this gist Sep 2, 2025.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@

    sudo tee /lib/systemd/system/haproxy.service >/dev/null <<'EOF'
    [Unit]
    Description=HAProxy Load Balancer
    Documentation=man:haproxy(1)
    Documentation=file:/usr/share/doc/haproxy/configuration.txt.gz
    After=network-online.target rsyslog.service
    Wants=network-online.target

    [Service]
    EnvironmentFile=-/etc/default/haproxy
    EnvironmentFile=-/etc/sysconfig/haproxy
    BindReadOnlyPaths=/dev/log:/var/lib/haproxy/dev/log
    Environment="CONFIG=/etc/haproxy/haproxy.cfg" "CONFIG_DIR=/etc/haproxy/haproxy.d/" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock"
    ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -f $CONFIG_DIR -p $PIDFILE $EXTRAOPTS
    ExecReload=/usr/sbin/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS
    ExecReload=/bin/kill -USR2 $MAINPID
    KillMode=mixed
    Restart=always
    SuccessExitStatus=143
    Type=notify


    [Install]
    WantedBy=multi-user.target
    EOF


    systemctl daemon-reload

    systemctl restart haproxy