Skip to content

Commit beb34cb

Browse files
aweilandmbanting
authored andcommitted
chore: Added worker configuration to uvicorn startup (#1896)
1 parent 2844489 commit beb34cb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

compose/fastapi/start-backend-datadog

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ set -o errexit
1212
set -o pipefail
1313
set -o nounset
1414

15+
16+
NUM_WORKERS=1
17+
if command -v nproc >/dev/null 2>&1; then
18+
NUM_WORKERS=$(nproc)
19+
echo "Starting app with $NUM_WORKERS workers..."
20+
else
21+
echo "No nproc, defaulting to 1 worker..."
22+
fi
23+
1524
# https://www.uvicorn.org/settings/
1625
export UVICORN_HOST="0.0.0.0"
1726
export UVICORN_PORT=80
1827

1928
uvicorn main:app \
2029
--host ${UVICORN_HOST} --port ${UVICORN_PORT} \
2130
--reload --proxy-headers \
22-
--log-config uvicorn_disable_logging.json
31+
--log-config uvicorn_disable_logging.json --workers ${NUM_WORKERS}

0 commit comments

Comments
 (0)