jflow/run.py

59 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Jflow 一键启动脚本
"""
import subprocess
import sys
import time
import threading
from pathlib import Path
def run_backend():
"""运行后端服务"""
print("🚀 启动后端API服务...")
subprocess.run([sys.executable, "start.py"])
def run_frontend():
"""运行前端服务"""
time.sleep(3) # 等待后端启动
print("🎨 启动前端开发服务器...")
subprocess.run([sys.executable, "start_frontend.py"])
def main():
print("🌟 Jflow 一键启动")
print("=" * 50)
# 检查依赖
try:
import uvicorn
print("✅ 后端依赖检查通过")
except ImportError:
print("❌ 缺少后端依赖,请运行: pip install -r requirements.txt")
return
# 检查Node.js
try:
subprocess.run(["node", "--version"], check=True, capture_output=True)
print("✅ Node.js 检查通过")
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ 未找到Node.js请先安装Node.js")
print("💡 安装指南: https://nodejs.org/")
return
# 启动后端和前端
backend_thread = threading.Thread(target=run_backend)
frontend_thread = threading.Thread(target=run_frontend)
backend_thread.start()
frontend_thread.start()
try:
backend_thread.join()
frontend_thread.join()
except KeyboardInterrupt:
print("\n👋 Jflow已停止")
if __name__ == "__main__":
main()