Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

perf: Use guvicorn as ASGI web server

Clémence Lesné69677219246f
diff --git a/Dockerfile b/Dockerfile
index be0944c..7ca8f22 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -42,4 +42,4 @@ COPY --chown=appuser:appuser . /app
WORKDIR /app
-CMD ["bash", "-c", "WEB_CONCURRENCY=4 uvicorn main:api --host 0.0.0.0 --port 8080 --proxy-headers --no-server-header --timeout-keep-alive 60 --header x-version:${VERSION}"]
+CMD ["bash", "-c", "gunicorn main:api --bind 0.0.0.0:8080 --proxy-protocol --workers 4 --worker-class uvicorn.workers.UvicornWorker"]
diff --git a/Makefile b/Makefile
index d62f970..62bb9bc 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ test:
@echo "➡️ Running deptry..."
python3 -m deptry \
--ignore-notebooks \
- --per-rule-ignores "DEP002=aiohttp|uvicorn" \
+ --per-rule-ignores "DEP002=aiohttp|gunicorn" \
.
@echo "➡️ Running Pytest..."
@@ -94,15 +94,13 @@ tunnel:
devtunnel host $(tunnel_name)
dev:
- VERSION=$(version_full) API__EVENTS_DOMAIN=$(tunnel_url) python3 -m uvicorn main:api \
- --header x-version:$${VERSION} \
- --no-server-header \
- --port 8080 \
- --proxy-headers \
+ VERSION=$(version_full) API__EVENTS_DOMAIN=$(tunnel_url) python3 -m gunicorn main:api \
+ --bind 0.0.0.0:8080 \
+ --proxy-protocol \
--reload \
- --reload-include .env \
- --reload-include config.yaml \
- --timeout-keep-alive 60
+ --reload-extra-file .env \
+ --reload-extra-file config.yaml \
+ --worker-class uvicorn.workers.UvicornWorker
build:
$(docker) build \
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 3b68b6f..070c41d 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -7,4 +7,3 @@ pytest-asyncio==0.23.6 # Required for pytest
pytest-repeat==0.9.3 # Required for pytest
pytest-xdist[psutil]==3.5.0 # Required for pytest
pytest==8.1.1
-watchfiles==0.21.0 # Required for uvicorn auto-reload
diff --git a/requirements.txt b/requirements.txt
index 971ad4a..f65a6df 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,6 +10,7 @@ azure-identity==1.15.0 # Required for all Azure SDKs
azure-monitor-opentelemetry==1.3.0
azure-search-documents==11.6.0b3
fastapi==0.110.1
+gunicorn==22.0.0
jinja2==3.1.3
json-repair==0.13.0
mistune==3.0.2
@@ -32,4 +33,3 @@ tenacity==8.2.3
tiktoken==0.6.0
twilio==9.0.5
typing-extensions==4.11.0
-uvicorn[standard]==0.28.0