ahpest_start.sh 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. NAME="AhPestDjangoWeb" # Name of the application
  3. DJANGODIR=/code/AhPestDjangoWeb # Django project directory
  4. SOCKFILE=/code/AhPestDjangoWeb/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=1 # how many worker processes should Gunicorn spawn
  8. DJANGO_SETTINGS_MODULE=AhPestDjangoWeb.settings # which settings file should Django use
  9. DJANGO_WSGI_MODULE=AhPestDjangoWeb.wsgi # WSGI module name
  10. echo "Starting $NAME as `whoami`"
  11. # Activate the virtual environment
  12. cd $DJANGODIR
  13. export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
  14. export PYTHONPATH=$DJANGODIR:$PYTHONPATH
  15. python manage.py makemigrations
  16. python manage.py migrate
  17. python manage.py collectstatic
  18. # Start your Django Unicorn
  19. # Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
  20. exec gunicorn ${DJANGO_WSGI_MODULE}:application \
  21. --name $NAME \
  22. --workers $NUM_WORKERS \
  23. --user=$USER --group=$GROUP \
  24. --bind=unix:$SOCKFILE \
  25. --log-level=debug \
  26. --log-file=-