fix(portable): gateway 启动卡死/Dashboard 拒连 (issue #46/#48)
根因:Windows-Start.bat 在 gateway 启动【前】就打开 http://127.0.0.1:18789, 而慢 U 盘上 OpenClaw 首次启动要几十秒 staging bundled deps,浏览器打开时 端口还没监听 → "127.0.0.1 拒绝连接",用户以为坏了。 修复: - 新增 lib/wait-gateway.bat:后台轮询端口(每2s,最多~5min),gateway 真正 LISTENING 后才打开 Dashboard;超时回退到 Config Center。 - Windows-Start.bat:移除 gateway 启动前的过早开浏览器,改由 wait-gateway 在 ready 后触发;加"首次启动需 30-90 秒"的明确提示。 - Mac-Start.command 本就先轮询 curl 再开浏览器,无此问题。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -144,18 +144,24 @@ start /B "" "%NODE_BIN%" "%CONFIG_SERVER%\server.js" >nul 2>&1
|
|||||||
REM Wait for config server to start
|
REM Wait for config server to start
|
||||||
timeout /t 2 /nobreak >nul
|
timeout /t 2 /nobreak >nul
|
||||||
|
|
||||||
REM Open both Dashboard and Config Center
|
REM IMPORTANT: 不要在 gateway 启动前就开 Dashboard 浏览器!
|
||||||
echo Opening Dashboard and Config Center...
|
REM 慢 U 盘上 OpenClaw 首次启动要 staging bundled deps(几十秒),
|
||||||
timeout /t 1 /nobreak >nul
|
REM 过早打开 http://127.0.0.1:18789 会"拒绝连接",是 issue #46/#48 的根因。
|
||||||
|
REM 改为后台等待器:轮询端口,gateway 真正 LISTENING 后再开 Dashboard。
|
||||||
REM Open OpenClaw Dashboard first
|
echo Opening Config Center...
|
||||||
start "" http://127.0.0.1:%PORT%/#token=uclaw
|
|
||||||
|
|
||||||
REM Open Config Center (Node.js web UI) second
|
|
||||||
start "" http://127.0.0.1:18788/
|
start "" http://127.0.0.1:18788/
|
||||||
|
|
||||||
echo Browsers opened. Starting OpenClaw Gateway on port %PORT%...
|
REM 后台等待器:每 2s 探测 %PORT%,最多 ~5 分钟(150 次),监听到就开 Dashboard
|
||||||
|
start /B "" cmd /c ""%UCLAW_DIR%lib\wait-gateway.bat" %PORT%"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ========================================
|
||||||
|
echo Starting OpenClaw Gateway on port %PORT%...
|
||||||
|
echo First run on a USB drive may take 30-90 seconds
|
||||||
|
echo (unpacking bundled components). Please wait;
|
||||||
|
echo the Dashboard opens automatically when ready.
|
||||||
echo DO NOT close this window while using U-Claw!
|
echo DO NOT close this window while using U-Claw!
|
||||||
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
cd /d "%CORE_DIR%"
|
cd /d "%CORE_DIR%"
|
||||||
|
|||||||
28
portable/lib/wait-gateway.bat
Normal file
28
portable/lib/wait-gateway.bat
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
@echo off
|
||||||
|
REM wait-gateway.bat - open Dashboard only after the Gateway is actually listening.
|
||||||
|
REM Fixes issue #46/#48: on slow USB drives the gateway needs tens of seconds to
|
||||||
|
REM stage bundled deps on first run; opening http://127.0.0.1:PORT before it is
|
||||||
|
REM LISTENING shows "connection refused" and users think it is broken.
|
||||||
|
REM Usage (called in background by Windows-Start.bat): wait-gateway.bat PORT
|
||||||
|
REM Polls every 2s, up to 150 tries (~5 min). Opens the browser once ready.
|
||||||
|
|
||||||
|
set "PORT=%~1"
|
||||||
|
if "%PORT%"=="" set "PORT=18789"
|
||||||
|
|
||||||
|
set /a TRIES=0
|
||||||
|
:wait_loop
|
||||||
|
netstat -an | findstr ":%PORT% " | findstr "LISTENING" >nul 2>&1
|
||||||
|
if %errorlevel%==0 goto :ready
|
||||||
|
set /a TRIES+=1
|
||||||
|
if %TRIES% geq 150 goto :timeout
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
goto :wait_loop
|
||||||
|
|
||||||
|
:ready
|
||||||
|
timeout /t 1 /nobreak >nul
|
||||||
|
start "" http://127.0.0.1:%PORT%/#token=uclaw
|
||||||
|
exit /b 0
|
||||||
|
|
||||||
|
:timeout
|
||||||
|
start "" http://127.0.0.1:18788/
|
||||||
|
exit /b 1
|
||||||
Reference in New Issue
Block a user