fix: 修复多个高优 Issue (#160, #165, #156, #159, #151)

- #160 Gateway 死循環: _autoPairAndReconnect 后不调用 reconnect() 避免重置计数器
- #165 readConfig 未定义: 替换为内联 fs.readFileSync/writeFileSync
- #156 systemd PATH: findOpenclawBin 添加 npm 全局路径, systemd 服务注入 PATH
- #159 Docker 双容器冲突: 新增 DISABLE_GATEWAY_SPAWN 环境变量开关
- #151 Gateway 检测冲突: linuxCheckGateway 验证进程名, 拒绝操作非 OpenClaw 进程
This commit is contained in:
晴天
2026-03-30 23:13:24 +08:00
parent 87d7c227d8
commit f5d32c377c
5 changed files with 311 additions and 11 deletions

View File

@@ -324,12 +324,16 @@ export class WsClient {
console.warn('[ws] reloadGateway 失败(非致命):', e)
}
console.log('[ws] 配对成功2秒后重新连接...')
// 修复 #160: 不调用 reconnect()(它会重置 _autoPairAttempts 导致无限循环),
// 而是直接重连一次。如果仍然失败_autoPairAttempts 不会被重置,不会再次触发自动修复。
console.log('[ws] 配对成功3秒后重新连接...')
setTimeout(() => {
if (!this._intentionalClose) {
this.reconnect()
this._reconnectAttempts = 0
this._closeWs()
this._doConnect()
}
}, 2000)
}, 3000)
} catch (e) {
console.error('[ws] 自动配对失败:', e)
this._setConnected(false, 'error', `配对失败: ${e}`)