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
17 changes: 16 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Remote Attach",
"name": "Python Debugger: Remote Attach (Celery)",
"type": "debugpy",
"request": "attach",
"connect": {
Expand All @@ -15,6 +15,21 @@
"remoteRoot": "."
}
]
},
{
"name": "Python Debugger: Remote Attach (Django)",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5679
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
}
15 changes: 14 additions & 1 deletion compose/local/django/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ set -o nounset


python manage.py migrate
exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
if [ "$DJANGO_DEBUG" = "1" ]; then
echo "Starting Django under debugpy..."
python -m debugpy --listen 0.0.0.0:5679 \
-m uvicorn config.asgi:application \
--host 0.0.0.0 \
--reload \
--reload-include '*.html'
Comment on lines +9 to +15
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix variable handling and add exec for proper signal propagation.

Two issues with the debug path:

  1. Missing default value: With set -o nounset (line 5), the script will fail if DJANGO_DEBUG is undefined. Use parameter expansion to provide a default.

  2. Missing exec: The debug branch doesn't use exec (unlike line 18), leaving the shell process alive. This prevents proper signal handling (e.g., SIGTERM won't reach the Python process), causing graceful shutdown issues.

Apply this diff:

-if [ "$DJANGO_DEBUG" = "1" ]; then
+if [ "${DJANGO_DEBUG:-0}" = "1" ]; then
   echo "Starting Django under debugpy..."
-  python -m debugpy --listen 0.0.0.0:5679 \
+  exec python -m debugpy --listen 0.0.0.0:5679 \
     -m uvicorn config.asgi:application \
     --host 0.0.0.0 \
     --reload \
     --reload-include '*.html'
🤖 Prompt for AI Agents
In compose/local/django/start around lines 9 to 15, the debug branch fails under
set -o nounset when DJANGO_DEBUG is undefined and does not use exec so signals
don't propagate to the Python process; update the condition to use parameter
expansion (e.g. ${DJANGO_DEBUG:-0}) to provide a default value and prepend exec
to the python -m debugpy command so the shell is replaced by the Python process
for proper signal handling.

else
echo "Starting Django normally..."
exec uvicorn config.asgi:application \
--host 0.0.0.0 \
--reload \
--reload-include '*.html'
fi
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ services:
required: false
ports:
- "8000:8000"
command: /start
- "5679:5679"
command: >
python -m debugpy --listen 0.0.0.0:5679 -m uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Command overrides the conditional startup logic in the start script.

The hardcoded command completely bypasses the compose/local/django/start script, which contains conditional logic to enable debugpy only when DJANGO_DEBUG=1. This means:

  • The debugger will always be active, regardless of the DJANGO_DEBUG variable
  • The conditional startup logic in the start script becomes unreachable and useless
  • There's no way to disable debugging without modifying docker-compose.yml

Solution: Remove the command override to allow the start script's conditional logic to work:

-    command: >
-        python -m debugpy --listen 0.0.0.0:5679 -m uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'

Then ensure DJANGO_DEBUG=1 is set in .envs/.local/.django to enable debugging during development, or add it to the environment section:

environment:
  - DJANGO_DEBUG=1
🤖 Prompt for AI Agents
In docker-compose.yml around lines 37-38, the hardcoded command that launches
debugpy/uvicorn overrides the service's start script and forces the debugger on;
remove this command override so the service uses compose/local/django/start
(which contains the DJANGO_DEBUG conditional), and ensure DJANGO_DEBUG is set to
enable debugging when desired (either by adding DJANGO_DEBUG=1 to
.envs/.local/.django or by adding it under the service's environment section).

networks:
- default
- antenna_network
Expand Down