Haproxy stats after service restart

Hi all!
I’m writing python plugin that collects Haproxy stats. Here is part of configuration file that I use, so the stats for particular process are available under http://ip_address:1936/haproxy?stats:

listen stats 0.0.0.0:1936
mode http
log global

    maxconn 5
    clitimeout      100s
    srvtimeout      100s

However once Haproxy service is restarted (sudo service restart) additional process appears that also listens on same ip-port. As a result on every single request I get randomly either ‘old’ or ‘new’ process statistics - I can differ those by looking at “General process Information”.
Is it intentional behaviour? Or maybe there are some additional steps that I need to perform?

have you checked that the service restart is stopping the older process and creating another, and is not just running 2.

I may be your restart script that has the issue.

ps -ef ?

I don’t think this is expected behavior, the listening socket is supposed to be closed right away (even if the process has some other things left to do, like serving other, still active connections). Does your python plugin use keepalive towards haproxy? Better disabled that.

Also I suggest you upgrade to the latest, just released 1.5.18 or 1.6.5 releases, they contain a few fixes regarding those things.

simonuk1
I noticed that when I did haproxy reload then new process was started with signal fish sent to the old one (-sf) and everything was fine (old was gone). On ther other hand on every restart I got another process, like:

haproxy 11713 1 0 May06 ? 00:00:46 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -D -p /var/run/haproxy.pid
haproxy 11812 1 0 May06 ? 00:00:46 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -D -p /var/run/haproxy.pid

lukastribus
Finally I upgraded haproxy from 1.5.4 to 1.6.4 and it looks like problem no longer appears. Indeed the restart script might have had some issues. My plugin did not influnce haproxy behaviour since it was off when I did those manual tests.

I just wonder what would be stats in case of haproxy reload (-sf) when there are two processes - old handling still active connections). Will I get only new process stats?

edit: I think I can answer myself. I tuned haproxy to keep existing connections (‘option http-keep-alive’) and after reload i have two processes but stats are coming only from the new one so it support lukastribut 's statement about closing listening socket.