Hi, I am using the runtime API to add/remove/modify entries in map files as described in this blog post, and it works fine for small numbers of commands at a time, but if there are too many commands at once I usually get an error after a few hundred commands have been processed:
2022/02/01 03:15:38 socat[29468] E write(5, 0x55f4b129ee30, 67): Broken pipe
This happens when using echo | socat
from the command line, for example:
for n in {1..500}; do echo "add map /etc/haproxy/test.map /test$n -"; done | socat stdio /run/haproxy.stat
And also if using the following perl code:
foreach my $kr (sort keys %filemap) {
push( @changes, "add map $mapfile $kr " . $filemap{$kr} );
}
# open new connection to haproxy socket
my $writesock = new IO::Socket::UNIX (
Peer => '/run/haproxy.stat',
Type => SOCK_STREAM,
);
if ( ! $writesock ) {
syslog('warning',"unable to connect to haproxy socket");
return;
}
print $writesock join("\n",@changes) . "\n";
close $writesock;
If I add a sleep(3)
before the close $writesock
in the perl code the issue seems to go away, but I wonder if there’s something else I should be doing.
\Should I be limiting the number of commands given at once, or doing something else with the socket before closing it?
1 post - 1 participant