@echo off chcp 936 > nul setlocal enabledelayedexpansion :: ================= 路径配置 ================= set REDIS_HOME=E:\ServerSpace\Redis-7.2.13-Windows-x64-msys2 set PG_HOME=E:\ServerSpace\pgsql set PROJECT_HOME=E:\ProductSpcae\ZhAgentOS1.0 :menu cls echo ============================== echo 服务控制面板 echo ============================== echo 【启动服务】 echo 1. 启动全部服务 echo 2. 启动基础服务(Redis + PostgreSQL) echo 3. 启动后端服务(Celery + Web) echo 4. 启动前端服务(UI) echo 5. 启动 Redis echo 6. 启动 PostgreSQL echo 7. 启动 Celery echo 8. 启动 Web echo 9. 启动 UI echo. echo 【重启服务】 echo 10. 重启全部服务 echo 11. 重启 Redis echo 12. 重启 PostgreSQL echo 13. 重启后端服务 echo. echo 【停止服务】 echo 20. 停止全部服务 echo 21. 停止 Redis echo 22. 停止 PostgreSQL echo 23. 停止后端服务 echo 24. 停止前端服务 echo. echo 0. 退出 echo ============================== set /p choice=请输入选项: if "%choice%"=="1" call :start_all if "%choice%"=="2" call :start_base if "%choice%"=="3" call :start_backend if "%choice%"=="4" call :start_ui if "%choice%"=="5" call :start_redis if "%choice%"=="6" call :start_pg if "%choice%"=="7" call :start_celery if "%choice%"=="8" call :start_web if "%choice%"=="9" call :start_ui if "%choice%"=="10" call :restart_all if "%choice%"=="11" call :restart_redis if "%choice%"=="12" call :restart_pg if "%choice%"=="13" call :restart_backend if "%choice%"=="20" call :stop_all if "%choice%"=="21" call :stop_redis if "%choice%"=="22" call :stop_pg if "%choice%"=="23" call :stop_backend if "%choice%"=="24" call :stop_ui if "%choice%"=="0" exit pause goto menu :: ================= 启动 ================= :start_all call :start_redis call :start_pg call :start_backend call :start_ui goto :eof :start_base call :start_redis call :start_pg goto :eof :start_backend call :start_celery call :start_web goto :eof :start_ui call :start_ui_only goto :eof :start_redis echo [Redis] 正在启动... tasklist | find /i "redis-server.exe" > nul if not errorlevel 1 ( echo [Redis] 已在运行 goto :eof ) start "" /min cmd /k "cd /d %REDIS_HOME% && redis-server.exe" timeout /t 2 > nul echo [Redis] 启动完成 goto :eof :start_pg echo [PostgreSQL] 正在启动... pg_isready -h 127.0.0.1 > nul 2>&1 if not errorlevel 1 ( echo [PostgreSQL] 已在运行 goto :eof ) cd /d %PG_HOME%\bin pg_ctl -D %PG_HOME%\data start > nul timeout /t 3 > nul echo [PostgreSQL] 启动完成 goto :eof :start_celery echo [Celery] 正在启动... start "" cmd /k "cd /d %PROJECT_HOME% && call venv\Scripts\activate && python main.py dev celery" echo [Celery] 启动完成 goto :eof :start_web echo [Web] 正在启动... start "" cmd /k "cd /d %PROJECT_HOME% && call venv\Scripts\activate && python main.py dev web" echo [Web] 启动完成 goto :eof :start_ui_only echo [前端 UI] 正在启动... start "" cmd /k "cd /d %PROJECT_HOME%\ui && npm run dev" start "" cmd /k "cd /d %PROJECT_HOME%\ui && npm run chat" echo [前端 UI] 启动完成 goto :eof :: ================= 停止 ================= :stop_all call :stop_ui call :stop_backend call :stop_pg call :stop_redis goto :eof :stop_redis echo [Redis] 正在停止... %REDIS_HOME%\redis-cli shutdown > nul 2>&1 taskkill /f /im redis-server.exe > nul 2>&1 echo [Redis] 已停止 goto :eof :stop_pg echo [PostgreSQL] 正在停止... cd /d %PG_HOME%\bin pg_ctl -D %PG_HOME%\data stop -m fast > nul echo [PostgreSQL] 已停止 goto :eof :stop_backend echo [后端] 正在停止... wmic process where "CommandLine like '%%main.py dev%%'" delete > nul echo [后端] 已停止 goto :eof :stop_ui echo [前端 UI] 正在停止... taskkill /f /im node.exe > nul echo [前端 UI] 已停止 goto :eof :: ================= 重启 ================= :restart_all echo 正在重启全部服务... call :stop_all timeout /t 3 > nul call :start_all goto :eof :restart_redis call :stop_redis timeout /t 2 > nul call :start_redis goto :eof :restart_pg call :stop_pg timeout /t 3 > nul call :start_pg goto :eof :restart_backend call :stop_backend timeout /t 2 > nul call :start_backend goto :eof