Skip to content

Commit

Permalink
Merge pull request #578 from jennydaman/devx
Browse files Browse the repository at this point in the history
Filter out healthcheck logging and properly raise exceptions in DEBUG mode
  • Loading branch information
jennydaman authored Sep 30, 2024
2 parents b520832 + 57f9f45 commit 755b0e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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

0 comments on commit 755b0e2

Please sign in to comment.