@echo off rem ============================================================================ rem Guanlan start.bat rem rem ASCII ONLY ON PURPOSE. Chinese text inside a .bat is codepage-dependent rem (console cp936 / cp65001 / system locale), and cmd.exe has been seen to rem mis-parse such lines and then try to EXECUTE parts of them rem ("'...' is not recognized as an internal or external command"). rem So every .bat in this package is pure ASCII; all Chinese guidance lives in rem README (see "README" text file at the install root) and docs\. rem The rule is enforced by src\entry_refs.py (check.bat reports it) and by the rem packer: a .bat with non-ASCII bytes never ships. rem rem Default (double-click) : no-window start via pythonw.exe + the launcher. rem A .bat is itself a console program, so Windows opens a window for a rem moment; this script exits at once and the window closes by itself. rem A .bat cannot avoid that flash. For a truly windowless start use the rem shortcut created by install.bat / install.ps1: rem [install dir]\start_guanlan.lnk (ASCII name: console / CI / scripts) rem [install dir] and Desktop: a .lnk with the Chinese product name rem Both point straight at .venv\Scripts\pythonw.exe, so neither cmd.exe nor rem Windows Script Host is involved. rem rem start.bat console : foreground mode (old behaviour). Keeps this window rem open and prints live logs; closing it stops serve. rem start.bat help : this text. rem rem Logs (docs section 11.2): logs\serve.log and logs\start_hidden.log. 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 ) if not exist "scripts\guanlan_start_hidden.py" ( echo [X] Missing launcher: scripts\guanlan_start_hidden.py echo The package is incomplete - re-extract it. check.bat reports this too. pause exit /b 3 ) rem No-window start: pythonw.exe has no console subsystem, so no window appears rem while the services run. /min is a belt-and-braces flag; the launcher exits rem as soon as serve is up. start "" /min ".venv\Scripts\pythonw.exe" "scripts\guanlan_start_hidden.py" 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 run start.bat with no argument. echo For a truly windowless start use the shortcut start_guanlan.lnk. 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): pythonw + browser. This cmd window echo blinks for a fraction of a second, then closes itself. echo start_guanlan.lnk zero window at all (created by install; target = pythonw.exe) 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) echo Docs: README text file at the install root; docs\ folder (design, runbook, data placement) exit /b 0