⚡️(asgi) use uvicorn to serve backend
This is a naive first switch from sync to async. This enables the backend to still answer to incomming requests while streaming LLM results to the user. For sure there is room for code cleaning and improvements, but this provides a nice improvement out of the box.
This commit is contained in:
committed by
Anthony LC
parent
5011db9bd7
commit
050b106a8f
18
src/backend/impress/asgi.py
Normal file
18
src/backend/impress/asgi.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
ASGI config for impress project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/dev/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from configurations.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "impress.settings")
|
||||
os.environ.setdefault("DJANGO_CONFIGURATION", "Development")
|
||||
os.environ.setdefault("PYTHON_SERVER_MODE", "async")
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -13,5 +13,6 @@ from configurations.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "impress.settings")
|
||||
os.environ.setdefault("DJANGO_CONFIGURATION", "Development")
|
||||
os.environ.setdefault("PYTHON_SERVER_MODE", "sync")
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
@@ -55,12 +55,13 @@ dependencies = [
|
||||
"nested-multipart-parser==1.6.0",
|
||||
"openai==2.14.0",
|
||||
"psycopg[binary]==3.3.2",
|
||||
"pycrdt==0.12.44",
|
||||
"pycrdt==0.12.44",
|
||||
"PyJWT==2.10.1",
|
||||
"python-magic==0.4.27",
|
||||
"redis<6.0.0",
|
||||
"requests==2.32.5",
|
||||
"sentry-sdk==2.48.0",
|
||||
"uvicorn==0.40.0",
|
||||
"whitenoise==6.11.0",
|
||||
]
|
||||
|
||||
|
||||
@@ -135,9 +135,15 @@
|
||||
}
|
||||
},
|
||||
"header": {
|
||||
"logo": {},
|
||||
"icon": {
|
||||
"src": "/assets/icon-docs.svg",
|
||||
"width": "32px"
|
||||
"style": {
|
||||
"width": "32px",
|
||||
"height": "auto"
|
||||
},
|
||||
"alt": "",
|
||||
"withTitle": true
|
||||
}
|
||||
},
|
||||
"waffle": {
|
||||
@@ -164,5 +170,26 @@
|
||||
]
|
||||
},
|
||||
"showMoreLimit": 9
|
||||
},
|
||||
"home": {
|
||||
"with-proconnect": false,
|
||||
"icon-banner": {
|
||||
"src": "/assets/icon-docs.svg",
|
||||
"style": {
|
||||
"width": "64px",
|
||||
"height": "auto"
|
||||
},
|
||||
"alt": ""
|
||||
}
|
||||
},
|
||||
"favicon": {
|
||||
"light": {
|
||||
"href": "/assets/favicon-light.png",
|
||||
"type": "image/png"
|
||||
},
|
||||
"dark": {
|
||||
"href": "/assets/favicon-dark.png",
|
||||
"type": "image/png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,11 +91,14 @@ backend:
|
||||
restartPolicy: Never
|
||||
|
||||
command:
|
||||
- "gunicorn"
|
||||
- "-c"
|
||||
- "/usr/local/etc/gunicorn/impress.py"
|
||||
- "impress.wsgi:application"
|
||||
- "--reload"
|
||||
- uvicorn
|
||||
- --app-dir=/app
|
||||
- --host=0.0.0.0
|
||||
- --timeout-graceful-shutdown=300
|
||||
- --limit-max-requests=20000
|
||||
- --lifespan=off
|
||||
- --reload
|
||||
- "impress.asgi:application"
|
||||
|
||||
createsuperuser:
|
||||
command:
|
||||
@@ -145,6 +148,9 @@ frontend:
|
||||
pullPolicy: Always
|
||||
tag: "latest"
|
||||
|
||||
securityContext:
|
||||
runAsNonRoot: false
|
||||
|
||||
yProvider:
|
||||
replicas: 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user