You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

  1. #!/usr/bin/env bash
  2. set -o errexit
  3. echo "Making staticfiles"
  4. static_dir=staticfiles
  5. mkdir -p client/dist/static
  6. if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then
  7. echo "Executing collectstatic"
  8. python manage.py collectstatic --noinput;
  9. fi
  10. echo "Initializing database"
  11. python manage.py wait_for_db
  12. python manage.py migrate
  13. python manage.py create_roles
  14. echo "Creating admin"
  15. if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
  16. python manage.py create_admin \
  17. --username "${ADMIN_USERNAME}" \
  18. --password "${ADMIN_PASSWORD}" \
  19. --email "${ADMIN_EMAIL}" \
  20. --noinput \
  21. || true
  22. fi
  23. echo "Starting django"
  24. # gunicorn --bind="0.0.0.0:${PORT:-8000}" --workers="${WORKERS:-4}" app.wsgi --timeout 300
  25. gunicorn --bind="0.0.0.0:${PORT:-8000}" --workers="${WORKERS:-1}" app.wsgi --timeout=300 &
  26. gunicorn_pid="$!"
  27. celery --app=app worker --loglevel=INFO --concurrency="${CELERY_WORKERS:-1}" &
  28. celery_pid="$!"
  29. while :; do
  30. if [[ ! -e "/proc/${celery_pid}" ]]; then
  31. echo "celery crashed" >&2
  32. exit 1
  33. elif [[ ! -e "/proc/${gunicorn_pid}" ]]; then
  34. echo "gunicorn crashed" >&2
  35. exit 2
  36. else
  37. sleep 10
  38. fi
  39. done