49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
快速启动AI审核服务的脚本
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
def main():
|
|
print("=" * 60)
|
|
print("🚀 启动TYCM AI审核服务")
|
|
print("=" * 60)
|
|
|
|
# 切换到服务目录
|
|
service_dir = os.path.join(os.path.dirname(__file__), "ai_review_service")
|
|
os.chdir(service_dir)
|
|
|
|
print(f"📁 当前目录: {os.getcwd()}")
|
|
|
|
# 检查requirements.txt
|
|
if not os.path.exists("requirements.txt"):
|
|
print("❌ requirements.txt 不存在!")
|
|
return
|
|
|
|
# 安装依赖
|
|
print("📦 安装Python依赖...")
|
|
try:
|
|
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
|
|
print("✅ 依赖安装成功")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ 依赖安装失败: {e}")
|
|
return
|
|
|
|
# 启动服务
|
|
print("🚀 启动FastAPI服务...")
|
|
print("📖 API文档将在: http://localhost:8080/docs")
|
|
print("🔗 健康检查: http://localhost:8080/api/v1/health")
|
|
print("-" * 60)
|
|
|
|
try:
|
|
subprocess.run([sys.executable, "run.py"], check=True)
|
|
except KeyboardInterrupt:
|
|
print("\n👋 服务已停止")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ 服务启动失败: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |