| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- @echo off
- rem ============================================================================
- rem 观澜 start.bat
- rem 2026-09-16 用户令: 启动观澜系统时"弹出的命令窗口"改为不弹出方式。
- rem
- rem 默认 (双击本文件) : 走**无窗口**启动 —— 交给 start_hidden.vbs (窗口样式 0),
- rem 后台起服务、等就绪、自动打开浏览器, 不留任何命令窗口。
- rem start.bat console : 前台模式 (旧行为) —— 在当前窗口里跑 serve 并实时打印日志,
- rem 只在排障时用; 关掉这个窗口等于停掉 serve。
- rem start.bat help : 说明。
- rem
- rem 为什么分开: 各组件服务本来就是 DETACHED_PROCESS 起的 (不弹窗), 唯一会弹的就是
- rem "在控制台里前台跑 guanlan.py serve" 这件事本身。排障又确实需要看见实时输出,
- rem 所以保留一个显式的 console 档, 而不是把日志彻底藏掉。
- rem ============================================================================
- chcp 65001 >nul
- set PYTHONUTF8=1
- cd /d "%~dp0"
- if /i "%~1"=="help" goto help
- if /i "%~1"=="console" goto console
- if /i "%~1"=="-c" goto console
- if not exist ".venv\Scripts\pythonw.exe" (
- echo [X] Not installed yet: .venv\Scripts\pythonw.exe not found
- echo Run install.bat first.
- pause
- exit /b 2
- )
- rem 无窗口启动: wscript 以隐藏窗口方式调用 pythonw.exe 跑启动器, 本窗口立即退出。
- wscript.exe //nologo "%~dp0start_hidden.vbs"
- exit /b 0
- :console
- if not exist ".venv\Scripts\python.exe" (
- echo [X] Not installed yet: .venv\Scripts\python.exe not found
- echo Run install.bat first. If install printed errors, send that screen back
- echo instead of continuing - the server cannot start without .venv.
- pause
- exit /b 2
- )
- echo [i] Foreground mode - this window stays open and shows live logs.
- echo Close it to stop the server; for no-window start just run start.bat with no argument.
- echo.
- ".venv\Scripts\python.exe" guanlan.py serve
- if errorlevel 1 (
- rem serve exits 1 in two different cases: the gateway never came up, or the gateway is
- rem up with at least one degraded module, e.g. Ollama not running. Probe healthz to tell
- rem them apart, otherwise a working server gets reported as "did not start".
- ".venv\Scripts\python.exe" -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:28084/healthz',timeout=6).status==200 else 1)" 2>nul
- if errorlevel 1 (
- echo.
- echo [X] Gateway did not come up ^(reason above^). Not opening the browser -
- echo a "site cannot be reached" page would look like a network problem.
- echo See logs\gateway.log
- pause
- exit /b 1
- )
- echo.
- echo [!] Gateway is up, but at least one module is degraded ^(the [DOWN] lines above^).
- echo Usual cause: local Ollama is not running or has no models pulled, which only
- echo disables the Q^&A / local-review pages. Every other page works.
- echo Details: logs/ for the degraded module.
- )
- start "" http://127.0.0.1:28084/
- echo.
- echo [i] Ops console - stop/start services, rebuild, clear products:
- echo http://127.0.0.1:28084/ops
- echo It stays available while component services are stopped (only the gateway must be up);
- echo buttons follow real state and the backend refuses impossible actions (HTTP 409).
- exit /b 0
- :help
- echo Usage:
- echo start.bat no-window start (default, recommended): hidden services + browser
- echo start.bat console foreground start with live logs (troubleshooting)
- echo stop.bat stop everything
- echo check.bat self-check
- echo Logs: logs\serve.log (no-window mode), logs\start_hidden.log (launcher trace)
- exit /b 0
|