Search code examples
ubuntuhaproxy

How to prevent multiple instances of HAProxy?


I am experiencing the problem cited in the answer to the below question - having multiple instances of HAProxy created inadvertently, so that the result of netstat -tulpn | grep 80 is several copies of HAProxy listening on a single port.

HAProxy random HTTP 503 errors

I know I can do kill PID# to get rid of the excess instances, but is there a way to prevent them? I see mention of a similar problem here:

https://github.com/haproxy/haproxy/issues/51

But that relates to multiple frontends in a single config. But is there a similar solution - a way to tell HAProxy to not initiate on a port that is already occupied?


Solution

  • Looks like the problem was this:

    My provisioner was starting HAProxy with one user, while a deployment system was restarting HAProxy with a separate user - so two copies of HAProxy ended up running. So, of course the solution was to make them both run via the same user.