Rohan Prabhu
Rohan Prabhu

Reputation: 7302

HAProxy not running stats socket

I installed haproxy from aur in Arch Linux and modified the config file a bit:

global
    maxconn     20000
    log         127.0.0.1 local0
    user        haproxy
    stats socket /run/haproxy/haproxy.sock mode 660 level admin
    stats timeout 30s
    chroot      /usr/share/haproxy
    pidfile     /run/haproxy.pid
    daemon

defaults
    mode    http
    stats   enable
    stats   uri /stats
    stats   realm Haproxy\ Statistics

frontend www-http
    bind 127.0.0.1:80
    default_backend www-backend

backend www-backend
    mode        http
    balance     roundrobin
    timeout     connect 5s
    timeout     server  30s
    timeout     queue   30s
    server  app1 127.0.0.1:5001 check
    server  app2 127.0.0.1:5002 check

I have made sure that the directory /run/haproxy exists and has permissions for the user haproxy to write to it:

 ツ ls -al /run/haproxy
total 0
drwxr-xr-x  2 haproxy root  40 May 13 21:37 .
drwxr-xr-x 27 root    root 720 May 13 22:00 ..

When I launch haproxy using systemctl start haproxy.service, it loads fine. I can even go to the /stats page and view stats, however, socat reports the following error:

ツ sudo socat unix-connect:/run/haproxy/haproxy.sock stdio
2016/05/13 22:04:11 socat[24202] E connect(5, AF=1 "/run/haproxy/haproxy.sock", 27): No such file or directory

I am at wits end and not able to understand what is happening. This is what I get from journalctl -xe:

May 13 21:56:31 rohanarch.local systemd[1]: Starting HAProxy Load Balancer...
May 13 21:56:31 rohanarch.local systemd[1]: Started HAProxy Load Balancer.
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]: haproxy-systemd-wrapper: executing /usr/bin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]: [WARNING] 133/215631 (20456) : config : missing timeouts for frontend 'www-http'.
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | While not properly invalid, you will certainly encounter various problems
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | with such a configuration. To fix this, please ensure that all following
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | timeouts are set to a non-zero value: 'client', 'connect', 'server'.

Basically, no errors/warnings or not even so much as an indication about the stats socket. Others who have faced a problem with the stats socket fail to get haproxy started. In my case, it starts up fine, but the socket just isn't creating.

Upvotes: 1

Views: 5396

Answers (2)

Ilgar Rustamov
Ilgar Rustamov

Reputation: 1

try to make selinux permissive with the command belowe and restart HAproxy service.

selinux command

Upvotes: 0

Suraj Singh
Suraj Singh

Reputation: 41

You need to manually create the directory yourself. Please ensure /run/haproxy exists. If it doesn't, then first create it with:

sudo mkdir /run/haproxy

This should resolve your issue.

Upvotes: 2

Related Questions