ShopTRAINING/start_api_debug.py

40 lines
974 B
Python
Raw Permalink Normal View History

2025-07-02 11:05:23 +08:00
#!/usr/bin/env python3
"""
以调试模式启动API服务器包含详细日志输出
"""
import subprocess
import sys
import os
def start_api_debug():
"""启动API服务器调试模式"""
print("启动API服务器调试模式...")
print("="*60)
# 切换到正确的目录
os.chdir(os.path.dirname(__file__))
# 启动命令
cmd = [
sys.executable,
"./server/api.py",
"--debug",
"--host", "0.0.0.0",
"--port", "5000"
]
print(f"执行命令: {' '.join(cmd)}")
print("="*60)
try:
# 直接运行,输出会实时显示
result = subprocess.run(cmd)
print(f"API服务器退出退出码: {result.returncode}")
except KeyboardInterrupt:
print("\n收到中断信号停止API服务器")
except Exception as e:
print(f"启动API服务器失败: {e}")
if __name__ == "__main__":
start_api_debug()