Skip to content

Commit

Permalink
Allow to run umap with asgi (#2209)
Browse files Browse the repository at this point in the history
Follow up of #1701 

cf #2174
  • Loading branch information
yohanboniface authored Oct 24, 2024
2 parents 455ddd4 + 13aa407 commit 2dcd61a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install: ## Install the dependencies

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

.PHONY: format
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ dependencies = [
"django-probes==1.7.0",
"Pillow==11.0.0",
"psycopg==3.2.3",
"pydantic==2.9.2",
"requests==2.32.3",
"rcssmin==1.1.3",
"rjsmin==1.2.3",
"social-auth-core==4.5.4",
"social-auth-app-django==5.4.2",
"websockets==13.1",
]

[project.optional-dependencies]
Expand All @@ -67,6 +65,12 @@ test = [
docker = [
"uwsgi==2.0.27",
]
sync = [
"channels==4.1.0",
"daphne==4.1.2",
"pydantic==2.9.2",
"websockets==13.1",
]

[project.scripts]
umap = "umap.bin:main"
Expand Down
15 changes: 15 additions & 0 deletions umap/asgi.py
Original file line number Diff line number Diff line change
@@ -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,
}
)
2 changes: 1 addition & 1 deletion umap/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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)

Expand Down

0 comments on commit 2dcd61a

Please sign in to comment.