Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion compose/local/django/start
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ python manage.py migrate
if [ "${DEBUGGER:-0}" = "1" ]; then
exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0
else
exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
WORKERS="${WEB_WORKERS:-1}"
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numeric comparison on line 15 will fail with a cryptic error if WEB_WORKERS is set to a non-numeric value (e.g., WEB_WORKERS=abc). Consider adding input validation before the comparison to ensure WORKERS is a positive integer, or use a more defensive comparison that handles non-numeric values gracefully.

Suggested change
WORKERS="${WEB_WORKERS:-1}"
WORKERS="${WEB_WORKERS:-1}"
# Ensure WORKERS is a positive integer; fall back to 1 if invalid
if ! [[ "$WORKERS" =~ ^[0-9]+$ ]] || [ "$WORKERS" -lt 1 ]; then
echo "Invalid WEB_WORKERS value '$WORKERS'. Falling back to 1 worker." >&2
WORKERS=1
fi

Copilot uses AI. Check for mistakes.
if [ "$WORKERS" -gt 1 ]; then
# --reload is incompatible with --workers, so skip it for multi-worker mode
exec uvicorn config.asgi:application --host 0.0.0.0 --workers "$WORKERS"
Comment on lines +14 to +17
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding documentation for the WEB_WORKERS environment variable. Based on the pattern in CLAUDE.md where DEBUGGER=1 is documented (lines 96-106), this new environment variable should also be documented to help developers understand how to use it for local development with multiple workers.

Copilot uses AI. Check for mistakes.
else
exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
fi
fi
4 changes: 3 additions & 1 deletion compose/production/django/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ set -o nounset

python /app/manage.py collectstatic --noinput

exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker
exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi \
--workers "${WEB_WORKERS:-4}" \
Comment on lines +9 to +10
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If WEB_WORKERS is set to a non-numeric value (e.g., WEB_WORKERS=abc) or zero/negative value, gunicorn will fail. Consider adding input validation to ensure WEB_WORKERS is a positive integer before using it, which would provide a clearer error message.

Suggested change
exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi \
--workers "${WEB_WORKERS:-4}" \
# Validate WEB_WORKERS as a positive integer, defaulting to 4 if unset or invalid
WEB_WORKERS_VALUE="${WEB_WORKERS:-4}"
if ! [[ "${WEB_WORKERS_VALUE}" =~ ^[1-9][0-9]*$ ]]; then
echo "Invalid WEB_WORKERS value '${WEB_WORKERS:-unset}'. Must be a positive integer. Falling back to 4." >&2
WEB_WORKERS_VALUE=4
fi
exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi \
--workers "${WEB_WORKERS_VALUE}" \

Copilot uses AI. Check for mistakes.
--bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker