I'm trying to start the Data Plane API on HAProxy boot using the instructions detailed here: https://www.haproxy.com/documentation/hapee/1-9r1/configuration/dataplaneapi/#using-the-haproxy-process-manager
My issue is I get this:
$ curl -X GET --user admin:mypassword "http://localhost:5555/v1/services/haproxy/info"
{"code":500,"message":"dial unix unix@/run/haproxy-master.sock: connect: no such file or directory"}
Which is odd because the file exists here:
$ ls -lah /run/haproxy-master.sock
srwxr-xr-x 1 root root 0 Jul 31 18:05 /run/haproxy-master.sock
And the process is running as the root user, so it should be able to see it:
$ sudo systemctl status haproxy.service
[sudo] password for user:
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-07-31 18:05:49 -05; 18h ago
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: 22227 ExecReload=/bin/kill -USR2 $MAINPID (code=exited, status=0/SUCCESS)
Process: 22739 ExecReload=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)
Process: 24307 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
Main PID: 24335 (haproxy)
Tasks: 12 (limit: 4418)
CGroup: /system.slice/haproxy.service
├─24335 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
├─24339 dataplaneapi --host 0.0.0.0 --port 5555 --haproxy-bin /usr/sbin/haproxy --config-file /etc/haproxy/haproxy.cfg --reload-cmd systemctl reload haproxy --reload-delay 5 --userlist controller
└─24341 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
Jul 31 18:05:47 lb01.private systemd[1]: Starting HAProxy Load Balancer...
Jul 31 18:05:48 lb01.private haproxy[24335]: [WARNING] 211/180548 (24335) : parsing [/etc/haproxy/haproxy.cfg:33]: 'option httplog' overrides previous 'log-format' in 'defaults' section.
Jul 31 18:05:48 lb01.private haproxy[24335]: [WARNING] 211/180548 (24335) : parsing [/etc/haproxy/haproxy.cfg:117]: keyword 'forceclose' is deprecated in favor of 'httpclose', and will not be supported by future versions.
Jul 31 18:05:49 lb01.private haproxy[24335]: [NOTICE] 211/180548 (24335) : New program 'api' (24339) forked
Jul 31 18:05:49 lb01.private haproxy[24335]: [NOTICE] 211/180548 (24335) : New worker #1 (24341) forked
Jul 31 18:05:49 lb01.private systemd[1]: Started HAProxy Load Balancer.
Jul 31 18:05:51 lb01.private haproxy[24335]: dial unix unix@/run/haproxy-master.sock: connect: no such file or directory
Jul 31 18:06:40 lb01.private haproxy[24335]: dial unix unix@/run/haproxy-master.sock: connect: no such file or directory
Aug 01 12:36:07 lb01.private haproxy[24335]: dial unix unix@/run/haproxy-master.sock: connect: no such file or directory
Here are what I think the relevant bits of my haproxy.cfg file are:
global
stats socket /run/haproxy.sock user haproxy group haproxy mode 660 level admin
userlist controller
user admin insecure-password mypassword
program api
command dataplaneapi --host 0.0.0.0 --port 5555 --haproxy-bin /usr/sbin/haproxy --config-file /etc/haproxy/haproxy.cfg --reload-cmd "systemctl reload haproxy" --reload-delay 5 --userlist controller
I fully understand that the "stats socket" declaration says /run/haproxy.sock, I've tried changing that to /run/haproxy-master.sock and restarting it as well. Same error. Not sure where the haproxy-master.sock file is coming from, guessing it's a default?
/run/haproxy-master.sock
is started as a socket when systemd runs haproxy:If not configured on the command line,
dataplaneapi
picks it up using env variables passed to the child process from the master, specifically fromHAPROXY_MWORKER
andHAPROXY_MASTER_CLI
variables. Why it fails to read it is beyond me here.Ran into the same problem...
Seems like this is influenced by systemd presets. Observed, that the problem was gone when starting haproxy from the cli directly w/o further parameters.
You can verify this by comparing the active unix sockets when haproxy has started from the cli or with systemd using
Make your changes accordingly :)