1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongrel-cluster
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Should-Start: $network
# Should-Stop: $network
# Short-Description: Start mongrel servers at boot time
### END INIT INFO
#
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
#
# mongrel_cluster Startup script for Mongrel clusters.
#
# chkconfig: - 85 15
# description: mongrel_cluster manages multiple Mongrel processes for use \
# behind a load balancer.
#
# Debianized by Filipe Lautert, filipe@icewall.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mongrel_cluster_ctl
NAME=mongrel-cluster
DESC=mongrel-cluster
test -x $DAEMON || exit 0
CONF_DIR=/etc/mongrel-cluster/sites-enabled
PID_DIR=/var/run/mongrel-cluster
USER=www-data
GROUP=www-data
DAEMON_OPTS="-c $CONF_DIR"
# Include mongrel-cluster defaults if available
if [ -f /etc/default/mongrel-cluster ] ; then
. /etc/default/mongrel-cluster
fi
set -e
# if we do not hae configuration files, skip the script
TOTAL_CONFS=$(ls $CONF_DIR | wc -l)
test $TOTAL_CONFS -ne 0 || exit 0
case "$1" in
start)
mkdir -p $PID_DIR
chown $USER:$GROUP $PID_DIR
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --chuid $USER:$GROUP \
--exec $DAEMON -- start $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --start --quiet --chuid $USER:$GROUP \
--exec $DAEMON -- stop $DAEMON_OPTS
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --start --quiet --chuid $USER:$GROUP \
--exec $DAEMON -- restart $DAEMON_OPTS
echo "$NAME."
;;
status)
echo -n "Status for $DESC: "
start-stop-daemon --start --quiet --chuid $USER:$GROUP \
--exec $DAEMON -- status $DAEMON_OPTS
;;
# actually jus calling restart
force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --start --quiet --chuid $USER:$GROUP \
--exec $DAEMON -- restart $DAEMON_OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
|