mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-12-01 14:04:04 +03:00
b6656379af
* chore: Replace deprecated uvicorn.workers with uvicorn-worker * Add package and fix worker class name --------- Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
35 lines
781 B
Bash
35 lines
781 B
Bash
#!/bin/bash
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
|
|
|
|
python /app/manage.py collectstatic --noinput
|
|
{% if cookiecutter.use_whitenoise == 'y' and cookiecutter.frontend_pipeline == 'Django Compressor' %}
|
|
compress_enabled() {
|
|
python << END
|
|
import sys
|
|
|
|
from environ import Env
|
|
|
|
env = Env(COMPRESS_ENABLED=(bool, True))
|
|
if env('COMPRESS_ENABLED'):
|
|
sys.exit(0)
|
|
else:
|
|
sys.exit(1)
|
|
|
|
END
|
|
}
|
|
|
|
if compress_enabled; then
|
|
# NOTE this command will fail if django-compressor is disabled
|
|
python /app/manage.py compress
|
|
fi
|
|
{%- endif %}
|
|
{%- if cookiecutter.use_async == 'y' %}
|
|
exec /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn_worker.UvicornWorker
|
|
{%- else %}
|
|
exec /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app
|
|
{%- endif %}
|