配置文件开启:
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
使用socat:
echo "help" | socat stdio /var/run/haproxy.sock
使用php:
<?php
$fp = stream_socket_client("unix:///var/run/haproxy.sock", $errno, $errstr);
if (!$fp) {
echo "$errstr \n";
}
fwrite($fp, 'help'."\r\n");
$res = "";
while (!feof($fp)) {
$res .= fgets($fp, 1024);
}
var_dump($res);
master sock,haproxy启动参数:
-S /var/run/haproxy-master.sock
echo "reload" | socat stdio /var/run/haproxy-master.sock