diff --git a/docker/gunicorn.conf.py b/docker/gunicorn.conf.py index 2141431b2..5273c5278 100644 --- a/docker/gunicorn.conf.py +++ b/docker/gunicorn.conf.py @@ -5,7 +5,6 @@ import structlog bind = "0.0.0.0:8000" workers = multiprocessing.cpu_count() * 2 + 1 -workers = 1 user = "passbook" group = "passbook" diff --git a/passbook/lib/sentry.py b/passbook/lib/sentry.py index 8aadcd385..99f51ef86 100644 --- a/passbook/lib/sentry.py +++ b/passbook/lib/sentry.py @@ -4,6 +4,7 @@ from botocore.client import ClientError from django.core.exceptions import DisallowedHost, ValidationError from django.db import InternalError, OperationalError, ProgrammingError from django_redis.exceptions import ConnectionInterrupted +from redis.exceptions import ConnectionError as RedisConnectionError from redis.exceptions import RedisError from rest_framework.exceptions import APIException from structlog import get_logger @@ -24,6 +25,7 @@ def before_send(event, hint): ConnectionInterrupted, APIException, ConnectionResetError, + RedisConnectionError, WorkerLostError, DisallowedHost, ConnectionResetError, diff --git a/passbook/root/asgi.py b/passbook/root/asgi.py index 915c59299..b3d6936e5 100644 --- a/passbook/root/asgi.py +++ b/passbook/root/asgi.py @@ -76,6 +76,10 @@ class ASGILogger: return self.start = time() + if scope["type"] == "lifespan": + # https://code.djangoproject.com/ticket/31508 + # https://github.com/encode/uvicorn/issues/266 + return await self.app(scope, receive, self.send_hooked) async def send_hooked(self, message: Message) -> None: @@ -115,6 +119,6 @@ class ASGILogger: ) -application = SentryAsgiMiddleware( - ASGILogger(guarantee_single_callable(get_default_application())) +application = ASGILogger( + guarantee_single_callable(SentryAsgiMiddleware(get_default_application())) )