TraceStudio/server/debug_run.py

36 lines
1.0 KiB
Python
Raw Permalink Normal View History

2026-01-12 21:51:45 +08:00
"""
Debug launcher for TraceStudio backend.
Usage:
python server/debug_run.py
This script starts debugpy listener on port 5678 and then launches uvicorn.
It waits for the debugger to attach before starting the application.
"""
import subprocess
import sys
import os
def main():
# Ensure debugpy is installed
try:
import debugpy # type: ignore
except Exception:
print("debugpy is not installed. Please run: pip install debugpy")
sys.exit(1)
# Start debugpy listener in this process and wait for client
import debugpy # type: ignore
host = "0.0.0.0"
port = 5678
print(f"Starting debugpy listener on {host}:{port}, waiting for client...")
debugpy.listen((host, port))
debugpy.wait_for_client()
print("Debugger attached, starting uvicorn...")
# Launch uvicorn as module in the same process
os.execv(sys.executable, [sys.executable, "-m", "uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "8000"])
if __name__ == "__main__":
main()