Setting up resque-web in rails 3.0

#!/bin/sh
#
# redis        init file for starting up the redis daemon
#
# chkconfig:   – 20 80
# description: Starts and stops the redis daemon.

# Source function library.
. /etc/rc.d/init.d/functions

name="rackup-resque-web"
PATH=$PATH:/opt/ruby-enterprise-1.8.7-2011.03/bin/
pidfile="/var/run/$name.pid"
lockfile=/var/lock/subsys/$name
logfile=/srv/hoge/log/$name.log

start() {
    echo -n $"Starting $name: "
    cd /srv/hoge
    rackup config/resque_config.ru >$logfile 2>&1 &
^—echo $! >$pidfile
    retval=$?
    [ $retval -eq 0 ] && touch $lockfile && daemon /bin/true
^—echo
    return $retval
}

stop() {
    echo -n $"Stopping $name: "
    killproc -p $pidfile $name
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop

    start
}

reload() {
    false
}

rh_status() {
    status -p $pidfile $name
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
^—status)
^—^—rh_status && exit 0
        $1
        ;;
    restart)
        $1
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 2
esac
exit $?

Google Buzz

Leave a comment

Your comment