Files
AItst/AIMonitor/simple_start.py
2026-02-08 14:33:45 +08:00

57 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
简单启动脚本 - AI监控系统
"""
import os
import sys
import time
import subprocess
from pathlib import Path
def main():
print("=== AI监控系统启动 ===")
# 检查当前目录
base_dir = Path(__file__).parent
os.chdir(base_dir)
# 创建必要目录
os.makedirs("videos", exist_ok=True)
os.makedirs("YOLO_Pipe_results", exist_ok=True)
print("正在启动服务...")
try:
# 启动RTSP服务
print("启动RTSP视频流处理服务...")
rtsp_process = subprocess.Popen([sys.executable, "rtsp_service_ws.py"])
# 等待RTSP服务启动
time.sleep(2)
# 启动HTTP服务
print("启动静态文件服务...")
http_process = subprocess.Popen([sys.executable, "static_server.py"])
print("\n=== 系统启动完成 ===")
print("RTSP WebSocket服务: ws://localhost:8765")
print("静态文件服务: http://localhost:5000")
print("\n按 Ctrl+C 停止所有服务")
# 等待用户中断
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\n正在停止服务...")
rtsp_process.terminate()
http_process.terminate()
rtsp_process.wait()
http_process.wait()
print("所有服务已停止")
except Exception as e:
print(f"启动失败: {e}")
if __name__ == "__main__":
main()