docker_start.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. NAME="website" # Name of the application
  3. DJANGODIR=/code/Website # Django project directory
  4. USER=root # the user to run as
  5. GROUP=root # the group to run as
  6. NUM_WORKERS=1 # how many worker processes should Gunicorn spawn
  7. DJANGO_SETTINGS_MODULE=Website.settings # which settings file should Django use
  8. DJANGO_WSGI_MODULE=Website.wsgi # WSGI module name
  9. echo "Starting $NAME as `whoami`"
  10. # Activate the virtual environment
  11. cd $DJANGODIR
  12. export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
  13. export PYTHONPATH=$DJANGODIR:$PYTHONPATH
  14. #pip install -Ur requirements.txt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com && \
  15. # pip install gunicorn -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
  16. python manage.py makemigrations
  17. python manage.py migrate
  18. python manage.py collectstatic --noinput
  19. python manage.py compress --force
  20. # Start your Django Unicorn
  21. # Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
  22. exec gunicorn ${DJANGO_WSGI_MODULE}:application \
  23. --name $NAME \
  24. --workers $NUM_WORKERS \
  25. --user=$USER --group=$GROUP \
  26. --bind 0.0.0.0:8000 \
  27. --log-level=debug \
  28. --log-file=-