Wednesday, January 2, 2013

django startup script

#!/bin/sh -u


ROOT_DIR="/data/www"

PIDFILE="${ROOT_DIR}/django.pid"

SITE_DIR="${ROOT_DIR}/site"

USER="vova"


MANAGE="$SITE_DIR/wmf/manage.py"

COMMAND="${SITE_DIR}/.env/bin/python"

PORT="10080"

HOST="127.0.0.1"

OPTIONS="$MANAGE runfcgi method=threaded host=${HOST} port=${PORT} pidfile=${PIDFILE}"


case "$1" in

      start)

            echo "Starting django site ...";

              /sbin/start-stop-daemon -S -p ${PIDFILE} -c ${USER}  --exec  $COMMAND -- $OPTIONS

      ;;

      stop)

           echo "Stoping django site  ...";

            /sbin/start-stop-daemon -Kp ${PIDFILE}

            test -f ${PIDFILE} && rm ${PIDFILE}

      ;;

      restart|reload)

            echo "Restarting api2 server ...";

            $0 stop;

            sleep 1;

            $0 start;

      ;;

      *)

      echo "use $0: stop|start"

      ;;

esac



where (django-1.5):

# ls -1a /data/www/site
.env/
.git/
.gitignore
README.md
requirements.txt
wmf/



# ls -1a /data/www/site/wmf/
manage.py
media/
static/
wmf/

No comments: