#!/bin/sh
#
# fastladder-server: Fastladder RSS Reader Server
#
# chkconfig: - 06 99
# description: Fastladder was very fast Web Bases RSS Reader
# processname: fastladder-server
#

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

. /var/www/fastladder/momonga-fastladder.conf

RETVAL=0

start() {
    echo -n $"Starting FastLadder Server: "
    daemon /usr/sbin/fastladder-server
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fastladder-server
}

stop() {
    echo -n $"Stopping FastLadder Server: "
    pid=`ps -ef | grep "[r]uby ./script/server -d -e $OF_RAILS_ENV" | awk '{ print $2 }'`
    kill $pid
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/fastladder-server
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
	sleep 3
        start
        ;;
    condrestart)
        if [ -f /var/lock/subsys/fastladder-server ]; then
            stop
	    sleep 3
            start
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|condrestart}"
        ;;
esac
exit $RETVAL
