Skip to content

Commit

Permalink
fix(api): move gunicorn worker config to python file (#2854)
Browse files Browse the repository at this point in the history
### Description

Passing the --lifespan flag to gunicorn does not forward the option to
uvicorn.
  • Loading branch information
jooola committed Dec 29, 2023
1 parent 35d7eac commit 43221d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Expand Up @@ -166,8 +166,7 @@ WORKDIR /app

CMD ["/usr/local/bin/gunicorn", \
"--workers=4", \
"--worker-class=uvicorn.workers.UvicornWorker", \
"--lifespan", "off", \
"--worker-class=libretime_api.gunicorn.Worker", \
"--log-file", "-", \
"--bind=0.0.0.0:9001", \
"libretime_api.asgi"]
Expand Down
3 changes: 1 addition & 2 deletions api/install/systemd/libretime-api.service
Expand Up @@ -25,8 +25,7 @@ Type=notify
KillMode=mixed
ExecStart=@@VENV_DIR@@/bin/gunicorn \
--workers 4 \
--worker-class uvicorn.workers.UvicornWorker \
--lifespan off \
--worker-class libretime_api.gunicorn.Worker \
--log-file - \
--bind unix:/run/libretime-api.sock \
libretime_api.asgi
Expand Down
5 changes: 5 additions & 0 deletions api/libretime_api/gunicorn.py
@@ -0,0 +1,5 @@
from uvicorn.workers import UvicornWorker # pylint: disable=import-error


class Worker(UvicornWorker):
CONFIG_KWARGS = {"lifespan": "off"}

0 comments on commit 43221d9

Please sign in to comment.