On Wed, May 20, 2009 at 05:03:08PM -0500, Jeremy wrote:
> While we're on the subject, in case anyone else wants to use it (or knows a
> better way of doing this)... I stuck this in my haproxy init.d scrip (using
> CentOS/RedHat). I'm not sure how to make it do the fancy green [ OK ] output
> like start/stop does but that's ok.
I don't know for the colors, but I have comments below
> reload() {
> /usr/local/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
here you use $BASENAME ...
> if [ $? -ne 0 ]; then
> echo "Errors found in configuration file, check it with '$BASENAME
> check'."
> return 1
> fi
> /usr/local/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -sf $(pidof
> haproxy)
...and here "haproxy".
> sleep 1
don't do that. If you add sleep, it will only make things work by pure
luck and slow your system down for nothing.
> pidof haproxy > /var/run/$BASENAME.pid
better use -p /var/run/$BASENAME.pid like this :
/usr/local/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p
/var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid 2>/dev/null)
That way haproxy sets the pid(s) file itself and checks that file, it does
not rely on a tricky "pidof" call nor the presence of a "sleep" call.
Regards,
Willy