Skip to content

Commit

Permalink
Merge pull request #662 from aiarena/feat/maintenance-mode
Browse files Browse the repository at this point in the history
Release v1.10.11
  • Loading branch information
lladdy authored Dec 14, 2023
2 parents 9a1e08c + a698d84 commit b9eba47
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions aiarena/core/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.http import HttpResponse
from django.shortcuts import render


def maintenance(get_response):
def middleware(request):
response = HttpResponse(
render(request, "maintenance.html"),
status=200,
)
return response

return middleware
15 changes: 15 additions & 0 deletions aiarena/frontend/templates/maintenance.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "base.html" %}

{% block header %}{% endblock %}
{% block sidebar %}{% endblock %}

{% block content %}
<div class="divider"><span></span><span><h2>AI Arena is currently under maintenance</h2></span><span></span></div>
<div id="inner_content">
<center>
AI Arena is currently under scheduled technical maintenance. <br />
We are upgrading our systems to improve site performance and reliability.<br />
Please check back in a while. It shouldn't take longer than 60 minutes.
</center>
</div>
{% endblock %}
9 changes: 8 additions & 1 deletion aiarena/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,11 @@ def get_discord_client_secret():
MATCH_TAG_PER_MATCH_LIMIT = 32

# If a primary field isn't specified on models, add an auto ID field. This affects all loaded modules.
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

def str_to_bool(s):
return s.lower() in ("yes", "y", "true", "1")

MAINTENANCE_MODE = str_to_bool(os.getenv("MAINTENANCE_MODE", "False"))
if MAINTENANCE_MODE:
MIDDLEWARE = ["aiarena.core.middleware.maintenance"] + MIDDLEWARE

0 comments on commit b9eba47

Please sign in to comment.