fix: only run configureOpenClaw once per clawId, not on every WS reconnect

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-24 14:31:31 +08:00
parent 029f7fe0a9
commit 4a1a2de300

View File

@@ -52,6 +52,9 @@ class ClawClient {
// 最近一次 WS 错误是否是证书时间问题NTP 未同步) // 最近一次 WS 错误是否是证书时间问题NTP 未同步)
this._certTimeError = false; this._certTimeError = false;
// 记录已为哪个 clawId 配置过 openclaw防止 WS 重连时重复执行)
this._openClawConfigured = null;
// systemd watchdog // systemd watchdog
this._sdTimer = null; this._sdTimer = null;
@@ -391,9 +394,12 @@ class ClawClient {
led.status.setApps(); led.status.setApps();
led.display.showTime(); led.display.showTime();
log.info('clawd', `已激活 claw_id = ${this._cfg.claw_id}`); log.info('clawd', `已激活 claw_id = ${this._cfg.claw_id}`);
if (this._cfg.claw_id && this._openClawConfigured !== this._cfg.claw_id) {
this._openClawConfigured = this._cfg.claw_id;
this._configureOpenClaw(this._cfg.claw_id); this._configureOpenClaw(this._cfg.claw_id);
} }
} }
}
// ── OpenClaw 配置 ──────────────────────────────────────────────────────────── // ── OpenClaw 配置 ────────────────────────────────────────────────────────────