From 552ddda909407ce0b626860de2a330e8589c918f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 11 Dec 2021 19:55:09 +0100 Subject: [PATCH] lifecycle: use custom worker class Signed-off-by: Jens Langhammer --- lifecycle/gunicorn.conf.py | 2 +- lifecycle/worker.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lifecycle/worker.py diff --git a/lifecycle/gunicorn.conf.py b/lifecycle/gunicorn.conf.py index 8aaff4ac5..fc4958878 100644 --- a/lifecycle/gunicorn.conf.py +++ b/lifecycle/gunicorn.conf.py @@ -16,7 +16,7 @@ try: except KeyError: pass -worker_class = "uvicorn.workers.UvicornWorker" +worker_class = "lifecycle.worker.DjangoUvicornWorker" # Docker containers don't have /tmp as tmpfs if os.path.exists("/dev/shm"): # nosec worker_tmp_dir = "/dev/shm" # nosec diff --git a/lifecycle/worker.py b/lifecycle/worker.py new file mode 100644 index 000000000..41d09d5cb --- /dev/null +++ b/lifecycle/worker.py @@ -0,0 +1,13 @@ +"""Uvicorn worker""" +from uvicorn.workers import UvicornWorker + + +class DjangoUvicornWorker(UvicornWorker): + """Custom configured Uvicorn Worker without lifespan""" + + CONFIG_KWARGS = { + "loop": "uvloop", + "http": "httptools", + "lifespan": "off", + "ws": "wsproto", + }