feat: vscode debug config

This commit is contained in:
a7m-1st 2025-10-21 18:04:45 +03:00
parent d5d8ba7202
commit dc93c58f5b
6 changed files with 878 additions and 805 deletions

View file

@ -2,6 +2,8 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"mrmlnc.vscode-json5"
"mrmlnc.vscode-json5",
"ms-python.python",
"ms-python.debugpy"
]
}

16
.vscode/launch.json vendored
View file

@ -50,5 +50,21 @@
"http://127.0.0.1:7777/**"
]
},
{
"name": "Debug Python Backend (Attach)",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend",
"remoteRoot": "."
}
],
"justMyCode": false
}
]
}

25
.vscode/tasks.json vendored
View file

@ -26,6 +26,31 @@
"endsPattern": "^.*\\[startup\\] Electron App.*$"
}
}
},
{
"label": "Start Python Backend Debug",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy",
"Bypass",
"-File",
"${workspaceFolder}/backend/start_debug.ps1"
],
"options": {
"cwd": "${workspaceFolder}/backend"
},
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new",
"showReuseMessage": true,
"clear": false
},
"isBackground": true,
"problemMatcher": []
}
]
}

View file

@ -36,6 +36,20 @@ app_logger.info(f"Loading routers with prefix: '{prefix}'")
auto_include_routers(api, prefix, "app/controller")
app_logger.info("All routers loaded successfully")
# Check if debug mode is enabled via environment variable
if os.environ.get('ENABLE_PYTHON_DEBUG') == 'true':
try:
import debugpy
DEBUG_PORT = int(os.environ.get('DEBUG_PORT', '5678'))
app_logger.info(f"Debug mode enabled - Starting debugpy server on port {DEBUG_PORT}")
debugpy.listen(("localhost", DEBUG_PORT))
app_logger.info(f"Debugger ready for attachment on localhost:{DEBUG_PORT}")
#📝 In VS Code: Run 'Debug Python Backend (Attach)' configuration
# Don't wait for client automatically - let it attach when ready
except ImportError:
app_logger.info("⚠️ debugpy not available, install with: uv add debugpy")
except Exception as e:
app_logger.info(f"⚠️ Failed to start debugpy: {e}")
dir = pathlib.Path(__file__).parent / "runtime"

View file

@ -19,6 +19,7 @@ dependencies = [
"traceroot>=0.0.7",
"nodejs-wheel>=22.18.0",
"numpy>=1.23.0,<2.0.0",
"debugpy>=1.8.17",
]

1623
backend/uv.lock generated

File diff suppressed because it is too large Load diff