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