feat(docker): add WEB_THREADS to run gunicorn workers with threads

This commit is contained in:
Herculino Trotta committed 2026-11-20 12:55:34 -03:00
1 parent 0f5f925683
commit 9ba91383cd
3 files changed
+7 -1

No files matched your search

+3
View File
@@ -23,6 +23,9 @@ SQL_PORT=5432
# Gunicorn
WEB_CONCURRENCY=4
# Threads per web worker. Each worker is a full copy of the app in memory; threads share it.
# For low traffic, WEB_CONCURRENCY=1 with WEB_THREADS=4 uses far less memory.
WEB_THREADS=1
# App Configs
# Enable this if you want to keep deleted transactions in the database
+2
View File
@@ -192,6 +192,8 @@ To create the first user, open the container's console using Unraid's UI, by cli
| ENABLE_SOFT_DELETE | true\|false | false | Whether to enable transactions soft delete, if enabled, deleted transactions will remain in the database. Useful for imports and avoiding duplicate entries. |
| KEEP_DELETED_TRANSACTIONS_FOR | int | 365 | Time in days to keep soft deleted transactions for. If 0, will keep all transactions indefinitely. Only works if ENABLE_SOFT_DELETE is true. |
| TASK_WORKERS | int | 1 | How many workers to have for async tasks. One should be enough for most use cases |
| WEB_CONCURRENCY | int | 1 | How many web worker processes to run. Each one is a full copy of the app in memory |
| WEB_THREADS | int | 1 | How many threads each web worker runs. Threads share their worker's memory, so `WEB_CONCURRENCY=1` with `WEB_THREADS=4` serves more requests at once with less RAM than 2 workers |
| IMPORT_TEMP_ROOT | string | /usr/src/app/temp | Where uploaded import files wait to be processed. Defaults to the `temp` folder inside the app folder. Must be writable and shared between the web and task processes. |
| CACHE_ROOT | string | /var/tmp | The writable folder the file-based caches are stored in. |
| DEMO | true\|false | false | If demo mode is enabled. |
+2 -1
View File
@@ -21,4 +21,5 @@ python manage.py setup_oauth
# Check for updates on startup instead of waiting for the next periodic run; never block boot on it
python manage.py procrastinate defer check_for_updates || true
exec gunicorn WYGIWYH.wsgi:application --bind 0.0.0.0:$INTERNAL_PORT --timeout 600
# Only pass --threads when WEB_THREADS is set, so a --threads in GUNICORN_CMD_ARGS still applies otherwise
exec gunicorn WYGIWYH.wsgi:application --bind 0.0.0.0:$INTERNAL_PORT --timeout 600 ${WEB_THREADS:+--threads "$WEB_THREADS"}