diff --git a/app/app/asgi.py b/app/app/asgi.py index 6ae490c..54792e0 100644 --- a/app/app/asgi.py +++ b/app/app/asgi.py @@ -1,6 +1,8 @@ import os - +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') from django.core.asgi import get_asgi_application +django_asgi_app = get_asgi_application() + from channels.auth import AuthMiddlewareStack from channels.sessions import SessionMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter @@ -8,8 +10,7 @@ from channels.routing import ProtocolTypeRouter, URLRouter from app.channels_middleware import JwtOrSessionAuthMiddleware -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') -django_asgi_app = get_asgi_application() + from .ws_urls import websocket_urlpatterns diff --git a/app/app/settings.py b/app/app/settings.py index 49ef1ab..188fbc1 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -59,8 +59,6 @@ INSTALLED_APPS = [ 'api', 'torrent', ] -if DEBUG: - INSTALLED_APPS = ["daphne"] + INSTALLED_APPS MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', diff --git a/app/app/utils.py b/app/app/utils.py index 8b07ae7..075bf1c 100644 --- a/app/app/utils.py +++ b/app/app/utils.py @@ -3,7 +3,7 @@ from django.http import StreamingHttpResponse import zlib import datetime import os -import aiofiles +import anyio from stat import S_IFREG from stream_zip import ZIP_64, stream_zip, async_stream_zip from channels.layers import get_channel_layer @@ -61,7 +61,7 @@ class StreamingZipFileResponse(StreamingHttpResponse): async def contents(path): try: - async with aiofiles.open(path, "rb") as f: + async with await anyio.open_file(path, "rb") as f: while chunk := await f.read(64 * 1024): yield chunk except RuntimeError as e: diff --git a/app/dev_run.sh b/app/dev_run.sh index 3058129..a8e76f2 100644 --- a/app/dev_run.sh +++ b/app/dev_run.sh @@ -1,5 +1,10 @@ +#!/bin/bash + +CORES=$(nproc) +WORKERS=$((2 * CORES + 1)) + cd /app/frontend && yarn dev & -cd /app && python manage.py runserver 0.0.0.0:8000 & +cd /app && uvicorn app.asgi:application --workers $WORKERS --host 0.0.0.0 --port 8000 --lifespan off --loop uvloop --ws websockets --reload & wait -n diff --git a/app/frontend/src/components/torrent/App.vue b/app/frontend/src/components/torrent/App.vue index 6d2efca..8151c3c 100644 --- a/app/frontend/src/components/torrent/App.vue +++ b/app/frontend/src/components/torrent/App.vue @@ -11,24 +11,26 @@ - + + + {{dm_status}} + - - - - + + Oxpanel - - - - - + + + + + +