fix: 确保 origin 更新后再重启 gateway
active+full provider 路径: addProviderSync → onDone(写 origin) → restartGateway 一次 之前顺序错误导致 gateway 用旧 origin 重启后再重启一次。 _updateOpenClawOrigin 只负责写盘,不再调 pkill。 移除 client.js 中已无用的 execSync 引入。 Made-with: Cursor
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { getNotifySocket } = require('./systemd-env');
|
const { getNotifySocket } = require('./systemd-env');
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
const { execSync, execFileSync } = require('child_process');
|
const { execFileSync } = require('child_process');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const log = require('./logger');
|
const log = require('./logger');
|
||||||
const { getBoxId } = require('./fingerprint');
|
const { getBoxId } = require('./fingerprint');
|
||||||
@@ -550,13 +550,6 @@ class ClawClient {
|
|||||||
|
|
||||||
writeFileSync(configFile, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
writeFileSync(configFile, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
||||||
log.info('clawd', `openclaw config 已更新: ${newOrigin}`);
|
log.info('clawd', `openclaw config 已更新: ${newOrigin}`);
|
||||||
|
|
||||||
try {
|
|
||||||
execSync('pkill -9 -x openclaw-gateway', { timeout: 3000 });
|
|
||||||
log.info('clawd', 'openclaw-gateway 已终止,等待自动重启');
|
|
||||||
} catch (_) {
|
|
||||||
log.info('clawd', 'openclaw-gateway 进程不存在,无需终止');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn('clawd', `openclaw config 更新失败: ${e.message}`);
|
log.warn('clawd', `openclaw config 更新失败: ${e.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,7 +282,6 @@ function applyFullProviderFromVps(provider, onDone) {
|
|||||||
log.warn('openclaw-provider', `拉模型失败,使用空列表: ${err.message}`);
|
log.warn('openclaw-provider', `拉模型失败,使用空列表: ${err.message}`);
|
||||||
}
|
}
|
||||||
addProviderSync(configFile, name, baseUrl, apiKey, list, defaultModel);
|
addProviderSync(configFile, name, baseUrl, apiKey, list, defaultModel);
|
||||||
restartGateway();
|
|
||||||
if (typeof onDone === 'function') {
|
if (typeof onDone === 'function') {
|
||||||
try {
|
try {
|
||||||
onDone();
|
onDone();
|
||||||
@@ -290,6 +289,7 @@ function applyFullProviderFromVps(provider, onDone) {
|
|||||||
log.warn('openclaw-provider', `onDone: ${e.message}`);
|
log.warn('openclaw-provider', `onDone: ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
restartGateway();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('openclaw-provider', `apply 写配置失败: ${e.message}`);
|
log.error('openclaw-provider', `apply 写配置失败: ${e.message}`);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user