Skip to content

Commit 6012175

Browse files
authored
Use granian instead of uvicorn (#344)
1 parent b25a037 commit 6012175

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

ai_chatbots/consumers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ async def create_checkpointer(
299299

300300
async def handle(self, message: str):
301301
"""Handle the incoming message and send the response."""
302+
if not message:
303+
return
302304
cookies = None
303305
try:
304306
await self.check_throttles()

config/nginx.conf.erb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,12 @@ http {
5151
return 204;
5252
}
5353

54-
location /ws {
55-
proxy_pass http://web:8001;
56-
proxy_http_version 1.1;
57-
proxy_set_header Upgrade $http_upgrade;
58-
proxy_set_header Connection $connection_upgrade;
59-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
60-
proxy_set_header Host $host;
61-
}
62-
6354
location / {
6455
proxy_pass http://web:8001;
6556
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
6657
proxy_set_header Host $host;
6758
proxy_redirect off;
59+
proxy_buffering off;
6860
}
6961

7062
}

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ social-auth-app-django = "^5.2.0"
7070
social-auth-core = {extras = ["openidconnect"], version = "^4.4.2"}
7171
starlette = "0.48.0"
7272
ulid-py = "^1.0.0"
73-
uvicorn = {extras = ["standard"], version = "^0.37.0"}
7473
granian = "^2.5.4"
7574
open-learning-ai-tutor = "^0.2.12"
7675

scripts/run-django-dev.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ python3 manage.py createcachetable
1313
# run ONLY data migrations
1414
RUN_DATA_MIGRATIONS=true python3 manage.py migrate --noinput
1515

16-
uvicorn main.asgi:application --reload --host 0.0.0.0 --port 8001
17-
18-
# production might best be run via a combo of gunicorn and uvicorn?
19-
#gunicorn main.asgi:application -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8001 --workers 4 --threads 2
16+
granian --interface asgi --host 0.0.0.0 --port 8001 --reload main.asgi:application

0 commit comments

Comments
 (0)