Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

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

Does look like a legible code?

share|improve this question

1 Answer 1

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
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

 
discard

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.