Configurable worker count. Closes #1668.

pull/1669/head
Mathijs de Bruin 2025-05-11 12:21:01 +01:00
rodzic 27ec8a75e5
commit 410036759e
2 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -34,6 +34,7 @@ services:
- WO_DEV
- WO_DEV_WATCH_PLUGINS
- WO_SECRET_KEY
- WEB_CONCURRENCY
restart: unless-stopped
oom_score_adj: 0
broker:

Wyświetl plik

@ -144,6 +144,18 @@ else
conf="nginx-ssl.conf"
fi
# Only set if `WEB_CONCURRENCY` is not defined, allows overriding.
# See: https://docs.gunicorn.org/en/latest/settings.html#workers
if [ -z "$WEB_CONCURRENCY" ]; then
# Default gunicorn worker count to 2 x availabe cores + 1
# nproc gives _available_ (rather than physicall present) CPU cores.
CPU_COUNT=$(nproc)
export WEB_CONCURRENCY=$((2*$CPU_COUNT+1))
echo "Setting WEB_CONCURRENCY based on $CPU_COUNT available CPU cores to start $WEB_CONCURRENCY gunicorn workers."
else
echo "Using pre-defined WEB_CONCURRENCY override to start $WEB_CONCURRENCY gunicorn workers."
fi
congrats
nginx -c $(pwd)/nginx/$conf