Skip to content

Commit 98b2a78

Browse files
committed
shutdown?
1 parent c17c575 commit 98b2a78

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

backend/healthchecks/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os
12
from django.conf import settings
23
from django.http import JsonResponse
34
from users.models import User
45

56

67
def healthcheck(request):
8+
if os.path.exists("shutdown"):
9+
return JsonResponse(
10+
{
11+
"status": "shutdown",
12+
"version": settings.GITHASH,
13+
},
14+
status=503,
15+
)
16+
717
User.objects.exists()
818

919
return JsonResponse(

backend/pycon/settings/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@
384384

385385
IS_RUNNING_TESTS = False
386386

387-
ECS_NETWORK_CONFIG = json.loads(env("ECS_NETWORK_CONFIG", default="{}"))
387+
try:
388+
ECS_NETWORK_CONFIG = json.loads(env("ECS_NETWORK_CONFIG", default=""))
389+
except json.decoder.JSONDecodeError:
390+
ECS_NETWORK_CONFIG = {}
391+
388392
ECS_SERVICE_ROLE = env("ECS_SERVICE_ROLE", default="")
389393

390394
SNS_WEBHOOK_SECRET = env("SNS_WEBHOOK_SECRET", default="")

backend/pycon/wsgi.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
import signal
12
import os
23

34
from django.core.wsgi import get_wsgi_application
45

56
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pycon.settings.prod")
67

8+
9+
def handle_sigterm(signum, frame):
10+
print("PyCon Received SIGTERM")
11+
with open("shutdown", "w") as f:
12+
f.write("shutdown")
13+
14+
15+
try:
16+
signal.signal(signal.SIGTERM, handle_sigterm)
17+
except ValueError:
18+
print("Could not set signal handler")
19+
20+
721
application = get_wsgi_application()

infrastructure/applications/cluster/load_balancer_task.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ resource "aws_ecs_task_definition" "traefik" {
5252

5353
dockerLabels = {
5454
"traefik.enable" = "true"
55-
"traefik.http.middlewares.retry.retry.attempts" = "2"
55+
"traefik.http.middlewares.retry.retry.attempts" = "4"
5656
"traefik.http.middlewares.retry.retry.initialInterval" = "100ms"
5757
}
5858

0 commit comments

Comments
 (0)