openclawsetup 2.8.5 → 2.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.mjs +60 -0
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -1959,6 +1959,63 @@ async function updateOpenClaw(cliName) {
1959
1959
  }
1960
1960
  }
1961
1961
 
1962
+ // ============ 安装后 Gateway 验证 ============
1963
+
1964
+ async function verifyAndStartGateway(cliName) {
1965
+ const config = getConfigInfo();
1966
+ const port = config.port || DEFAULT_GATEWAY_PORT;
1967
+
1968
+ console.log(colors.cyan('\n验证 Gateway 服务...'));
1969
+
1970
+ // 等待 Gateway 启动(onboard 可能刚启动 daemon,需要时间)
1971
+ await sleep(3000);
1972
+
1973
+ // 检查端口是否在监听
1974
+ const portCheck = getPortCheckOutput(port);
1975
+ if (portCheck.ok && hasListeningState(portCheck.output)) {
1976
+ // 端口在监听,再验证 health
1977
+ const health = gatewayHealthRequest(port);
1978
+ if (health.ok) {
1979
+ log.success('Gateway 运行正常');
1980
+ return;
1981
+ }
1982
+ }
1983
+
1984
+ // Gateway 未启动,尝试手动启动
1985
+ log.warn('Gateway 未就绪,正在尝试启动...');
1986
+
1987
+ const startResult = await ensureGatewayRunning(cliName, 'start');
1988
+ if (startResult.ok) {
1989
+ // 再次验证端口
1990
+ await sleep(2000);
1991
+ const recheck = getPortCheckOutput(port);
1992
+ if (recheck.ok && hasListeningState(recheck.output)) {
1993
+ log.success('Gateway 已启动');
1994
+ return;
1995
+ }
1996
+ }
1997
+
1998
+ // 仍然失败,尝试 restart
1999
+ log.warn('启动失败,尝试重启...');
2000
+ const restartResult = await ensureGatewayRunning(cliName, 'restart');
2001
+ if (restartResult.ok) {
2002
+ await sleep(2000);
2003
+ const recheck2 = getPortCheckOutput(port);
2004
+ if (recheck2.ok && hasListeningState(recheck2.output)) {
2005
+ log.success('Gateway 已重启成功');
2006
+ return;
2007
+ }
2008
+ }
2009
+
2010
+ // 所有尝试失败
2011
+ log.error(`Gateway 未能在端口 ${port} 上启动`);
2012
+ console.log(colors.yellow('\n请手动排查:'));
2013
+ console.log(` 1. 运行: ${colors.green(`${cliName} gateway start`)}`);
2014
+ console.log(` 2. 查看日志: ${colors.green(`${cliName} gateway logs`)}`);
2015
+ console.log(` 3. 检查端口: ${colors.green(`${cliName} status`)}`);
2016
+ console.log(` 4. 运行诊断: ${colors.green(`npx openclawsetup@latest --fix`)}`);
2017
+ }
2018
+
1962
2019
  // ============ 完成信息 ============
1963
2020
 
1964
2021
  function showCompletionInfo(cliName) {
@@ -2880,6 +2937,9 @@ async function main() {
2880
2937
  // 运行 onboard
2881
2938
  await runOnboard(cliName);
2882
2939
 
2940
+ // 验证 Gateway 是否启动,未启动则尝试启动
2941
+ await verifyAndStartGateway(cliName);
2942
+
2883
2943
  // 显示完成信息
2884
2944
  showCompletionInfo(cliName);
2885
2945
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "2.8.5",
3
+ "version": "2.8.6",
4
4
  "description": "OpenClaw 安装向导 - 智能安装、诊断、自动修复",
5
5
  "type": "module",
6
6
  "bin": {