Skip to content

Commit 9ce5ae6

Browse files
setup uvloop uvicorn worker
1 parent e28aa70 commit 9ce5ae6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ RUN apt-get update && \
1616

1717
COPY ./src /app/src
1818

19-
CMD ["gunicorn", "-c", "src/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "uvicorn.workers.UvicornWorker", "src.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "60", "--loop", "uvloop"]
19+
CMD ["gunicorn", "-c", "src/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "src.settings.gunicorn.UvloopUvicornWorker", "src.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "60", "--loop", "uvloop"]

src/settings/gunicorn.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import uptrace
22
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
3+
from uvicorn.workers import UvicornWorker
34
from src.secrets import Secrets
45

56

@@ -15,3 +16,7 @@ def post_fork(server, worker): # pylint: disable=unused-argument
1516
)
1617

1718
FastAPIInstrumentor.instrument_app(fastapi_server)
19+
20+
21+
class UvloopUvicornWorker(UvicornWorker):
22+
CONFIG_KWARGS = {"loop": "uvloop"}

0 commit comments

Comments
 (0)