switch from WSGI using uWSGI to ASGI using custom event loop based on uvicorn
This commit is contained in:
parent
b103205dfe
commit
6b3cc4c168
15 changed files with 610 additions and 8 deletions
|
@ -9,8 +9,25 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
|||
|
||||
import os
|
||||
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
from django.core.asgi import get_asgi_application
|
||||
from notify_sessions.routing import websocket_urlpatterns
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
django_asgi_app = get_asgi_application()
|
||||
|
||||
websocket_asgi_app = AllowedHostsOriginValidator(
|
||||
#AuthMiddlewareStack(
|
||||
URLRouter(
|
||||
websocket_urlpatterns
|
||||
)
|
||||
#)
|
||||
)
|
||||
|
||||
application = ProtocolTypeRouter({
|
||||
"http": django_asgi_app,
|
||||
"websocket": websocket_asgi_app,
|
||||
})
|
||||
|
|
|
@ -49,6 +49,7 @@ INSTALLED_APPS = [
|
|||
'channels',
|
||||
'files',
|
||||
'inventory',
|
||||
'notify_sessions',
|
||||
]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
|
@ -183,12 +184,10 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|||
|
||||
CHANNEL_LAYERS = {
|
||||
'default': {
|
||||
'BACKEND': 'channels.layers.InMemoryChannelLayer',
|
||||
# 'BACKEND': 'asgi_redis.RedisChannelLayer',
|
||||
# 'CONFIG': {
|
||||
# 'hosts': [('localhost', 6379)],
|
||||
# },
|
||||
'ROUTING': 'example.routing.channel_routing',
|
||||
'BACKEND': 'asgi_redis.RedisChannelLayer',
|
||||
'CONFIG': {
|
||||
'hosts': [('localhost', 6379)],
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue