timetracker/entrypoint.sh

24 lines
660 B
Bash
Raw Normal View History

2023-01-03 14:29:39 +01:00
#!/bin/bash
2023-01-03 13:04:05 +01:00
# Apply database migrations
2023-01-07 21:09:47 +01:00
set -euo pipefail
2023-01-03 13:04:05 +01:00
echo "Apply database migrations"
2023-01-20 15:06:42 +01:00
poetry run python manage.py migrate
2023-01-03 13:04:05 +01:00
2023-01-07 18:10:36 +01:00
echo "Collect static files"
2023-01-20 15:06:42 +01:00
poetry run python manage.py collectstatic --clear --no-input
2023-01-07 18:10:36 +01:00
_term() {
echo "Caught SIGTERM signal!"
kill -SIGTERM "$gunicorn_pid"
kill -SIGTERM "$django_q_pid"
}
trap _term SIGTERM
echo "Starting Django-Q cluster"
poetry run python manage.py qcluster & django_q_pid=$!
2023-01-20 15:40:07 +01:00
echo "Starting app"
poetry run python -m gunicorn --bind 0.0.0.0:8001 timetracker.asgi:application -k uvicorn.workers.UvicornWorker --access-logfile - --error-logfile - & gunicorn_pid=$!
wait "$gunicorn_pid" "$django_q_pid"