Skip to content

Commit

Permalink
Allow to use maintenance while the migrations are in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Dec 22, 2024
1 parent fbf76d7 commit b0121a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions config/views.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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"})
10 changes: 9 additions & 1 deletion scripts/celery_beat.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b0121a1

Please sign in to comment.