QubitProducts/bamboo — pull request #33 by sttts (2014-09-30 08:50:25+00:00)
Title: Synchronize haproxy reloads

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.