Skip to content

Instantly share code, notes, and snippets.

@omarkj
Created September 1, 2010 13:49
Show Gist options
  • Save omarkj/560703 to your computer and use it in GitHub Desktop.
Save omarkj/560703 to your computer and use it in GitHub Desktop.
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/haproxy
NAME=haproxy
DESC=proxy
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/haproxy ] ; then
. /etc/haproxy
fi
set -e
. /lib/lsb/init-functions
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- -f "/etc/haproxy/haproxy.cfg" -p "/var/run/$NAME.pid" || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
for pid in $(cat /var/run/$NAME.pid) ; do
/bin/kill $pid || return 4
done
rm -f /var/run/$NAME.pid
echo "$NAME."
;;
status)
status_of_proc -p /var/run/$NAME.pid "$DAEMON" haproxy && exit 0 || exit $?
;;
*)
echo "Usage: $NAME {start|stop|status}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment