chore: use asgi rather than wsgi

By relying on Django Channels and Daphne.
This requires a change in how the application is deployed to take that into account.
This commit is contained in:
Alexis Métaireau 2024-03-18 11:42:05 +01:00 committed by Yohan Boniface
parent a2b8145cde
commit 71943c0ab3
3 changed files with 20 additions and 1 deletions

View file

@ -28,6 +28,8 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"channels==4.0.0",
"daphne==4.1.0",
"Django==5.1.1",
"django-agnocomplete==2.2.0",
"django-environ==0.11.2",

16
umap/asgi.py Normal file
View file

@ -0,0 +1,16 @@
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "umap.settings")
# Initialize Django ASGI application early to ensure the AppRegistry
# is populated before importing code that may import ORM models.
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter(
{
"http": django_asgi_app,
# Just HTTP for now. (We can add other protocols later.)
}
)

View file

@ -19,7 +19,7 @@ env = environ.Env()
INTERNAL_IPS = env.list("INTERNAL_IPS", default=["127.0.0.1"])
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
ADMINS = tuple(parseaddr(email) for email in env.list("ADMINS", default=[]))
ASGI_APPLICATION = "umap.asgi.application"
DEBUG = env.bool("DEBUG", default=False)
@ -119,6 +119,7 @@ LANGUAGES = (
SECRET_KEY = env("SECRET_KEY", default=None)
INSTALLED_APPS = (
"daphne",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",