lifecycle: use custom worker class

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-11 19:55:09 +01:00
parent bafeff7306
commit 552ddda909
2 changed files with 14 additions and 1 deletions

View File

@ -16,7 +16,7 @@ try:
except KeyError: except KeyError:
pass pass
worker_class = "uvicorn.workers.UvicornWorker" worker_class = "lifecycle.worker.DjangoUvicornWorker"
# Docker containers don't have /tmp as tmpfs # Docker containers don't have /tmp as tmpfs
if os.path.exists("/dev/shm"): # nosec if os.path.exists("/dev/shm"): # nosec
worker_tmp_dir = "/dev/shm" # nosec worker_tmp_dir = "/dev/shm" # nosec

13
lifecycle/worker.py Normal file
View File

@ -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",
}