diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 231a5deb..305f061f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -83,8 +83,13 @@ cd /app python manage.py migrate --noinput python manage.py collectstatic --noinput +uwsgi_file="/app/docker/uwsgi.ini" +if [ "$DISPATCHARR_ENV" = "dev" ]; then + uwsgi_file="/app/docker/uwsgi.dev.ini" +fi + echo "🚀 Starting uwsgi..." -su - $POSTGRES_USER -c "cd /app && uwsgi --ini /app/docker/uwsgi.ini &" +su - $POSTGRES_USER -c "cd /app && uwsgi --ini $uwsgi_file &" uwsgi_pid=$(pgrep uwsgi | sort | head -n1) echo "✅ uwsgi started with PID $uwsgi_pid" pids+=("$uwsgi_pid") diff --git a/docker/uwsgi.dev.ini b/docker/uwsgi.dev.ini new file mode 100644 index 00000000..9bd0ab3f --- /dev/null +++ b/docker/uwsgi.dev.ini @@ -0,0 +1,42 @@ +[uwsgi] +; exec-before = python manage.py collectstatic --noinput +; exec-before = python manage.py migrate --noinput + +attach-daemon = celery -A dispatcharr worker -l info +attach-daemon = redis-server +attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application +attach-daemon = cd /app/frontend && npm run start + +# Core settings +chdir = /app +module = dispatcharr.wsgi:application +virtualenv = /dispatcharrpy +master = true +env = DJANGO_SETTINGS_MODULE=dispatcharr.settings +socket = /app/uwsgi.sock +chmod-socket = 777 +vacuum = true +die-on-term = true + +# Worker management (Optimize for I/O bound tasks) +workers = 4 +threads = 2 +enable-threads = true + +# Optimize for streaming +http = 0.0.0.0:5656 +http-keepalive = 1 +buffer-size = 65536 # Increase buffer for large payloads +post-buffering = 4096 # Reduce buffering for real-time streaming +http-timeout = 600 # Prevent disconnects from long streams +lazy-apps = true # Improve memory efficiency + +# Async mode (use gevent for high concurrency) +gevent = 100 +async = 100 + +# Performance tuning +thunder-lock = true +log-4xx = true +log-5xx = true +disable-logging = false diff --git a/docker/uwsgi.ini b/docker/uwsgi.ini index bd4cd574..ace423af 100644 --- a/docker/uwsgi.ini +++ b/docker/uwsgi.ini @@ -4,8 +4,7 @@ attach-daemon = celery -A dispatcharr worker -l info attach-daemon = redis-server -; attach-daemon = cd /app/frontend && npm run start -; attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application +attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application # Core settings chdir = /app