#! /bin/sh
# Installation
# - Move this to /etc/init.d/apex
# - chmod +x this
#
# Starting and stopping
# - Start: `service myservice start` or `/etc/init.d/myservice start`
# - Stop: `service myservice stop` or `/etc/init.d/myservice stop`

SITE_PATH="/home/boxer/devel/apex";
NAME=apex

DESC="Apex Daemons"
DAEMON="/usr/bin/php"

test -x $DAEMON || exit 0

set -e

case "$1" in
    start)
        echo -n "Starting ${DESC}: "
        start-stop-daemon --start --background --exec /bin/sh $SITE_PATH/apex core.rpc
        start-stop-daemon --start --background --exec /bin/sh $SITE_PATH/apex core.websocket
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        #start-stop-daemon --stop --pidfile $SITE_PATH/log/pids/websocket.pid
        echo "$NAME."

        ;;
    restart|force-reload)
        echo -n "Restarting $DESC: "
        echo "$NAME."
        ;;
    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
