diff --git a/config/settings/base.py b/config/settings/base.py index 727ffa2a74..6d04a9de6d 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -424,7 +424,7 @@ # Maintenance Mode # ------------------------------------------------------------------------------ # https://github.com/fabiocaccamo/django-maintenance-mode/tree/main#configuration-optional -MAINTENANCE_MODE = int(env("MAINTENANCE_MODE", default="0")) +MAINTENANCE_MODE_STATE_BACKEND = "maintenance_mode.backends.CacheBackend" # Password Reset # ------------------------------------------------------------------------------ diff --git a/config/views.py b/config/views.py index 30bde91d67..5d3895e19c 100644 --- a/config/views.py +++ b/config/views.py @@ -1,6 +1,9 @@ from django.conf import settings from django.http import JsonResponse from django.shortcuts import render +from maintenance_mode.decorators import ( + force_maintenance_mode_off, +) def app_version(request): @@ -11,5 +14,6 @@ def home_view(request): return render(request, "pages/home.html") +@force_maintenance_mode_off def ping(request): return JsonResponse({"status": "OK"}) diff --git a/scripts/celery_beat.sh b/scripts/celery_beat.sh index 96f552b9ea..65f9d5a607 100755 --- a/scripts/celery_beat.sh +++ b/scripts/celery_beat.sh @@ -1,15 +1,23 @@ #!/bin/bash printf "celery-beat" > /tmp/container-role -set -euo pipefail +set -eo pipefail ./wait_for_db.sh ./wait_for_redis.sh +if [[ "${AUTO_MAINTENANCE_MODE}" == "true" ]]; then + python manage.py maintenance_mode on +fi + python manage.py migrate --noinput python manage.py compilemessages -v 0 python manage.py load_redis_index +if [[ "${AUTO_MAINTENANCE_MODE}" == "true" ]]; then + python manage.py maintenance_mode off +fi + touch /tmp/healthy export NEW_RELIC_CONFIG_FILE=/etc/newrelic.ini