Allow to run umap with asgi (#2209)

Follow up of #1701 

cf #2174
This commit is contained in:
Yohan Boniface 2024-10-24 17:46:33 +02:00 committed by GitHub
commit 2dcd61a96d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 4 deletions

View file

@ -7,7 +7,7 @@ install: ## Install the dependencies
.PHONY: develop .PHONY: develop
develop: ## Install the test and dev dependencies develop: ## Install the test and dev dependencies
python3 -m pip install -e .[test,dev] python3 -m pip install -e .[test,dev,sync]
playwright install playwright install
.PHONY: format .PHONY: format

View file

@ -34,13 +34,11 @@ dependencies = [
"django-probes==1.7.0", "django-probes==1.7.0",
"Pillow==11.0.0", "Pillow==11.0.0",
"psycopg==3.2.3", "psycopg==3.2.3",
"pydantic==2.9.2",
"requests==2.32.3", "requests==2.32.3",
"rcssmin==1.1.3", "rcssmin==1.1.3",
"rjsmin==1.2.3", "rjsmin==1.2.3",
"social-auth-core==4.5.4", "social-auth-core==4.5.4",
"social-auth-app-django==5.4.2", "social-auth-app-django==5.4.2",
"websockets==13.1",
] ]
[project.optional-dependencies] [project.optional-dependencies]
@ -67,6 +65,12 @@ test = [
docker = [ docker = [
"uwsgi==2.0.27", "uwsgi==2.0.27",
] ]
sync = [
"channels==4.1.0",
"daphne==4.1.2",
"pydantic==2.9.2",
"websockets==13.1",
]
[project.scripts] [project.scripts]
umap = "umap.bin:main" umap = "umap.bin:main"

15
umap/asgi.py Normal file
View file

@ -0,0 +1,15 @@
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,
}
)

View file

@ -19,7 +19,7 @@ env = environ.Env()
INTERNAL_IPS = env.list("INTERNAL_IPS", default=["127.0.0.1"]) INTERNAL_IPS = env.list("INTERNAL_IPS", default=["127.0.0.1"])
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"]) ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
ADMINS = tuple(parseaddr(email) for email in env.list("ADMINS", default=[])) ADMINS = tuple(parseaddr(email) for email in env.list("ADMINS", default=[]))
ASGI_APPLICATION = "umap.asgi.application"
DEBUG = env.bool("DEBUG", default=False) DEBUG = env.bool("DEBUG", default=False)