Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to HA Proxy and Upstart Scripting. I am using, HA Proxy version 1.4.18 2011/09/16. I am trying to write an upstart script that will keep haproxy alive in case haproxy dies. This is what I have so far:

 if [ $(pgrep haproxy) ]; then
restart haproxy;
start haproxy;
end script

Does look like a legible code?

share|improve this question
up vote 3 down vote accepted

use this code and put it in "/etc/init/haproxy.conf". The "respawn" line will take care of supervising the daemon and restart it if necessary.

description     "HAProxy"

start on runlevel [2345]
stop on runlevel [016]

respawn limit 2 5

env CONF=/etc/haproxy/haproxy.cfg

pre-start script
    [ -r $CONF ]
end script

exec /usr/local/sbin/haproxy -db -f $CONF
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.