fix: 写盘 openclaw.json 后自动重启 gateway

- openclaw-provider.js: 新增 restartGateway(),在 removeProviderByName
  和 applyFullProviderFromVps 写盘成功后均调用,确保 inactive/active
  两路都能触发重启
- client.js: _updateOpenClawOrigin 去掉 CLAWD_OPENCLAW_GATEWAY_PKILL
  env var 门控,origin 变更后默认重启

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-04-03 10:50:29 +08:00
parent 12aedaaf85
commit 701251f19b
2 changed files with 21 additions and 10 deletions

View File

@@ -551,16 +551,11 @@ class ClawClient {
writeFileSync(configFile, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
log.info('clawd', `openclaw config 已更新: ${newOrigin}`);
// 默认不再 pkill gateway观察是否会自行重载恢复旧行为CLAWD_OPENCLAW_GATEWAY_PKILL=1
if (process.env.CLAWD_OPENCLAW_GATEWAY_PKILL === '1') {
try {
execSync('pkill -9 -x openclaw-gateway', { timeout: 3000 });
log.info('clawd', 'openclaw-gateway 已终止,等待自动重启');
} catch (_) {
log.info('clawd', 'openclaw-gateway 进程不存在,无需终止');
}
} else {
log.info('clawd', '已跳过 openclaw-gateway pkill需旧行为请设 CLAWD_OPENCLAW_GATEWAY_PKILL=1');
try {
execSync('pkill -9 -x openclaw-gateway', { timeout: 3000 });
log.info('clawd', 'openclaw-gateway 已终止,等待自动重启');
} catch (_) {
log.info('clawd', 'openclaw-gateway 进程不存在,无需终止');
}
} catch (e) {
log.warn('clawd', `openclaw config 更新失败: ${e.message}`);