diff --git a/Dockerfile b/Dockerfile index 4c39022..f25b16e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,4 +35,9 @@ ENV UPLOAD_PATH=/app/data/files EXPOSE 5000 -CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--timeout", "120", "wsgi:application"] +# gthread worker class so SSE long-poll connections don't starve regular requests. +# 2 workers x 16 threads = 32 concurrent slots; each SSE client just holds one thread. +CMD ["gunicorn", "--bind", "0.0.0.0:5000", \ + "--worker-class", "gthread", "--workers", "2", "--threads", "16", \ + "--timeout", "120", "--keep-alive", "65", \ + "wsgi:application"] diff --git a/nginx.example.conf b/nginx.example.conf index 1a39739..1d6e806 100644 --- a/nginx.example.conf +++ b/nginx.example.conf @@ -24,6 +24,23 @@ server { proxy_set_header Connection "upgrade"; } + # Server-Sent Events: Puffer aus, lange Read-Timeouts, sonst bricht die + # Live-Refresh-Verbindung nach ein paar Sekunden ab. + location /api/sync/events { + proxy_pass http://127.0.0.1:5000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_http_version 1.1; + proxy_buffering off; + proxy_cache off; + proxy_read_timeout 24h; + proxy_send_timeout 24h; + chunked_transfer_encoding on; + } + # CalDAV/CardDAV braucht spezielle Methoden location /dav/ { proxy_pass http://127.0.0.1:5000;