From 35953b6d51874640a8005be0ed13dfe4c610e79b Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Fri, 22 May 2026 09:06:48 +0200 Subject: [PATCH] Refactor: Dispatcharr (#14313) --- ct/dispatcharr.sh | 35 +++++++++++++++++++++++++++++----- install/dispatcharr-install.sh | 30 +++++++++++++++++++---------- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/ct/dispatcharr.sh b/ct/dispatcharr.sh index c656a9a4a..4aab46ab9 100644 --- a/ct/dispatcharr.sh +++ b/ct/dispatcharr.sh @@ -54,7 +54,7 @@ function update_script() { cp /opt/dispatcharr/.env /tmp/dispatcharr.env.backup fi if [[ -f /opt/dispatcharr/start-gunicorn.sh ]]; then - cp /opt/dispatcharr/start-gunicorn.sh /tmp/start-gunicorn.sh.backup + rm -f /opt/dispatcharr/start-gunicorn.sh fi if [[ -f /opt/dispatcharr/start-celery.sh ]]; then cp /opt/dispatcharr/start-celery.sh /tmp/start-celery.sh.backup @@ -83,9 +83,6 @@ function update_script() { if [[ -f /tmp/dispatcharr.env.backup ]]; then mv /tmp/dispatcharr.env.backup /opt/dispatcharr/.env fi - if [[ -f /tmp/start-gunicorn.sh.backup ]]; then - mv /tmp/start-gunicorn.sh.backup /opt/dispatcharr/start-gunicorn.sh - fi if [[ -f /tmp/start-celery.sh.backup ]]; then mv /tmp/start-celery.sh.backup /opt/dispatcharr/start-celery.sh fi @@ -105,7 +102,35 @@ function update_script() { rm -rf .venv $STD uv venv --clear $STD uv sync - $STD uv pip install gunicorn gevent celery redis daphne + $STD uv pip install uwsgi gevent celery redis daphne + cat <<'EOF' >/opt/dispatcharr/start-uwsgi.sh +#!/usr/bin/env bash +cd /opt/dispatcharr +set -a +source .env +set +a +exec .venv/bin/uwsgi \ + --chdir=/opt/dispatcharr \ + --module=dispatcharr.wsgi:application \ + --master \ + --workers=4 \ + --gevent=400 \ + --http=0.0.0.0:5656 \ + --http-keepalive=1 \ + --http-timeout=600 \ + --socket-timeout=600 \ + --buffer-size=65536 \ + --post-buffering=4096 \ + --lazy-apps \ + --thunder-lock \ + --die-on-term \ + --vacuum +EOF + chmod +x /opt/dispatcharr/start-uwsgi.sh + if grep -q 'start-gunicorn.sh' /etc/systemd/system/dispatcharr.service; then + sed -i 's|start-gunicorn.sh|start-uwsgi.sh|g' /etc/systemd/system/dispatcharr.service + systemctl daemon-reload + fi msg_ok "Updated Dispatcharr Backend" msg_info "Building Frontend" diff --git a/install/dispatcharr-install.sh b/install/dispatcharr-install.sh index 4b80a0fa8..7522ac283 100644 --- a/install/dispatcharr-install.sh +++ b/install/dispatcharr-install.sh @@ -38,7 +38,7 @@ msg_info "Installing Python Dependencies with uv" cd /opt/dispatcharr $STD uv venv --clear $STD uv sync -$STD uv pip install gunicorn gevent celery redis daphne +$STD uv pip install uwsgi gevent celery redis daphne msg_ok "Installed Python Dependencies" msg_info "Configuring Dispatcharr" @@ -118,7 +118,7 @@ server { proxy_set_header X-Forwarded-Proto \$scheme; } - # All other requests proxy to Gunicorn + # All other requests proxy to uWSGI location / { include proxy_params; proxy_pass http://127.0.0.1:5656; @@ -131,20 +131,30 @@ systemctl restart nginx msg_ok "Configured Nginx" msg_info "Creating Services" -cat </opt/dispatcharr/start-gunicorn.sh +cat </opt/dispatcharr/start-uwsgi.sh #!/usr/bin/env bash cd /opt/dispatcharr set -a source .env set +a -exec uv run gunicorn \\ +exec .venv/bin/uwsgi \\ + --chdir=/opt/dispatcharr \\ + --module=dispatcharr.wsgi:application \\ + --master \\ --workers=4 \\ - --worker-class=gevent \\ - --timeout=300 \\ - --bind 0.0.0.0:5656 \\ - dispatcharr.wsgi:application + --gevent=400 \\ + --http=0.0.0.0:5656 \\ + --http-keepalive=1 \\ + --http-timeout=600 \\ + --socket-timeout=600 \\ + --buffer-size=65536 \\ + --post-buffering=4096 \\ + --lazy-apps \\ + --thunder-lock \\ + --die-on-term \\ + --vacuum EOF -chmod +x /opt/dispatcharr/start-gunicorn.sh +chmod +x /opt/dispatcharr/start-uwsgi.sh cat </opt/dispatcharr/start-celery.sh #!/usr/bin/env bash @@ -184,7 +194,7 @@ After=network.target postgresql.service redis-server.service [Service] Type=simple WorkingDirectory=/opt/dispatcharr -ExecStart=/opt/dispatcharr/start-gunicorn.sh +ExecStart=/opt/dispatcharr/start-uwsgi.sh Restart=on-failure RestartSec=10 User=root