QubitProducts / bamboo

HAProxy auto configuration and auto service discovery for Mesos Marathon
Apache License 2.0
793 stars 214 forks source link

Synchronize haproxy reloads #33

Closed sttts closed 10 years ago

sttts commented 10 years ago

The haproxy reload command immediately returns, possibly before it has written a new /var/lib/haproxy.pid with its own pid. A (nearly) concurrent second reload command might read the old /var/lib/haproxy.pid and send a signal to the wrong haproxy process (the very old one). The consequence is that now two haproxies are running which do not know of each other.

This patch synchronizes the reload command executions by putting a semaphore around the exec.Command call. Furthermore, the haproxy reload command is modified in such a way that it waits for all processes in /var/lib/haproxy.pid to die before returning.

Fixes #30.

j1n6 commented 10 years ago

Thanks for the PRs. We are looking into it and testing it before the merge.

j1n6 commented 10 years ago

Thanks for your contribution.