-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
executable file
·78 lines (61 loc) · 1.77 KB
/
start.py
File metadata and controls
executable file
·78 lines (61 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""
AgentCalendar 启动脚本
快速启动前后端服务
"""
import os
import sys
import subprocess
import time
import threading
from pathlib import Path
def run_backend():
"""启动后端服务"""
print("🚀 启动后端服务...")
backend_dir = Path(__file__).parent / "backend"
os.chdir(backend_dir)
# 安装依赖
subprocess.run(
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True
)
# 启动 FastAPI 服务
subprocess.run(
["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
)
def run_frontend():
"""启动前端服务"""
print("🎨 启动前端服务...")
frontend_dir = Path(__file__).parent / "frontend"
os.chdir(frontend_dir)
# 安装依赖
if not (frontend_dir / "node_modules").exists():
print("📦 安装前端依赖...")
subprocess.run(["npm", "install"], check=True)
# 启动 Vite 开发服务器
subprocess.run(["npm", "run", "dev"])
def main():
"""主函数"""
print("=" * 60)
print("🎯 AgentCalendar - 智能日程管理系统")
print("=" * 60)
print()
print("正在启动服务...")
print("- 后端API: http://localhost:8000")
print("- 前端界面: http://localhost:3000")
print()
print("按 Ctrl+C 停止服务")
print("=" * 60)
try:
# 在后台启动后端
backend_thread = threading.Thread(target=run_backend)
backend_thread.daemon = True
backend_thread.start()
# 等待后端启动
time.sleep(3)
# 启动前端(主线程)
run_frontend()
except KeyboardInterrupt:
print("\n\n👋 正在停止服务...")
sys.exit(0)
if __name__ == "__main__":
main()