Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out healthcheck logging and properly raise exceptions in DEBUG mode #578

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,3 @@ RUN if [ "$ENVIRONMENT" = "production" ]; then \
env DJANGO_SETTINGS_MODULE=config.settings.common ./manage.py collectstatic; fi

CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "config.asgi:application"]

HEALTHCHECK --interval=30s --timeout=5s \
CMD curl -f http://localhost:8000/api/v1/users/ || exit 1
6 changes: 4 additions & 2 deletions chris_backend/core/middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from django.http import HttpResponse
from rest_framework import status
from rest_framework.renderers import JSONRenderer
from django.conf import settings

from collectionjson.renderers import CollectionJsonRenderer

Expand Down Expand Up @@ -40,7 +40,9 @@ def __init__(self, get_response):
def __call__(self, request):
return self.get_response(request)

def process_exception(self, request, exception):
def process_exception(self, request, exception: Exception):
if settings.DEBUG:
raise exception
print(exception, flush=True)
mime = request.META.get('HTTP_ACCEPT')
if mime != 'text/html':
Expand Down
8 changes: 7 additions & 1 deletion docker-compose_just.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
context: .
args:
ENVIRONMENT: local
command: python manage.py runserver 0.0.0.0:8000
command: bash -c 'python manage.py runserver 0.0.0.0:8000 2> >(grep -vF "HTTP GET /api/v1/users/ 200" 1>&2)'
ports:
- "8000:8000"
volumes: &CHRIS_VOLUMES
Expand All @@ -47,6 +47,12 @@ services:
local:
aliases:
- chrisdev.local # hard-coded in chrisomatic/*.yml
healthcheck:
test: [ "CMD", "sh", "-c", "curl -f http://localhost:8000/api/v1/users/ || exit 1" ]
interval: 5s
timeout: 5s
retries: 5
start_period: 60s
worker-mains:
image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev}
command: celery -A core worker -c 4 -l info -Q main1,main2
Expand Down
Loading