django_start 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. NAME="website" # Name of the application
  3. DJANGODIR=//var/www/Website # Django project directory
  4. SOCKFILE=/var/www/Website/run/gunicorn.sock # we will communicte using this unix socket
  5. USER=root # the user to run as
  6. GROUP=root # the group to run as
  7. NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
  8. DJANGO_SETTINGS_MODULE=Website.settings # which settings file should Django use
  9. DJANGO_WSGI_MODULE=Website.wsgi # WSGI module name
  10. echo "Starting $NAME as `whoami`"
  11. # Activate the virtual environment
  12. cd $DJANGODIR
  13. source /var/www/dev/python3/bin/activate
  14. export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
  15. export PYTHONPATH=$DJANGODIR:$PYTHONPATH
  16. # Create the run directory if it doesn't exist
  17. RUNDIR=$(dirname $SOCKFILE)
  18. test -d $RUNDIR || mkdir -p $RUNDIR
  19. # Start your Django Unicorn
  20. # Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
  21. exec /var/www/dev/python3/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  22. --name $NAME \
  23. --workers $NUM_WORKERS \
  24. --user=$USER --group=$GROUP \
  25. --bind=unix:$SOCKFILE \
  26. --log-level=debug \
  27. --log-file=-