BASEDIR="/home/merengue"
PIDFILE="$BASEDIR/pid/beta_merengue.pid"
VIRTUALENV=$BASEDIR/virtualenv/
SOCKET="$BASEDIR/sock/uwsgi.sock"
PROJECTNAME="beta_merengue"
LOGFILE="$BASEDIR/logs/beta_merengue.uwsgi.log"

export LC_ALL=es_ES.UTF-8

function start {
   echo "Iniciando Merengue Beta:"
   cd $BASEDIR
   . $BASEDIR/virtualenv/bin/activate
   $BASEDIR/bin/uwsgi -p 2 -C -M 4 -A 4 -m -s $SOCKET -H $VIRTUALENV $PROJECTNAME.wsgi --pythonpath $BASEDIR/merengueproject/beta_merengue/ --pidfile $PIDFILE -d $LOGFILE
}

function stop {
    echo "Terminando Merengue Beta:"
    pgrep uwsgi |xargs kill -9
}

case "$1" in
    start)
        start
    ;;

    stop)
        stop
    ;;
    restart)
        stop
        start
    ;;
    *)
        echo "Usage: /etc/init.d/merenguebeta {start|stop|restart}"
        exit 1
    ;;
esac

exit 0

