Vladimir
Vladimir

Reputation: 335

Haproxy and upstart scripting

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?

Upvotes: 1

Views: 701

Answers (1)

Flat
Flat

Reputation: 1640

If you want to make it nerdest and oneline script:

[ $(pgrep haproxy) ] && restart haproxy || start haproxy

BTW.. the easiest and best way to make it is to use an init.d custom script like this: http://mattiasgeniar.be/2010/11/04/a-custom-init-d-start-up-script-for-haproxy-start-stop-restart-reload-checkconfig/

Upvotes: 3

Related Questions