fix: use full path to find openclaw binary for root service
Made-with: Cursor
This commit is contained in:
@@ -398,18 +398,31 @@ class ClawClient {
|
|||||||
// ── OpenClaw 配置 ────────────────────────────────────────────────────────────
|
// ── OpenClaw 配置 ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
_configureOpenClaw(clawId) {
|
_configureOpenClaw(clawId) {
|
||||||
|
// 查找 openclaw 二进制(可能在用户目录下,不在 root PATH 中)
|
||||||
|
const candidates = [
|
||||||
|
'/home/sts/.npm-global/bin/openclaw',
|
||||||
|
'/usr/local/bin/openclaw',
|
||||||
|
'/usr/bin/openclaw',
|
||||||
|
];
|
||||||
|
const { existsSync } = require('fs');
|
||||||
|
const bin = candidates.find(p => existsSync(p));
|
||||||
|
if (!bin) {
|
||||||
|
log.warn('clawd', 'openclaw 未找到,跳过 allowedOrigins 配置');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const origins = JSON.stringify([
|
const origins = JSON.stringify([
|
||||||
'http://0.0.0.0:18789',
|
'http://0.0.0.0:18789',
|
||||||
`https://${clawId}.claw.cutos.ai`,
|
`https://${clawId}.claw.cutos.ai`,
|
||||||
]);
|
]);
|
||||||
execFileSync('openclaw', ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], {
|
execFileSync(bin, ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], {
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
});
|
});
|
||||||
log.info('clawd', `openclaw allowedOrigins 已配置: ${clawId}.claw.cutos.ai`);
|
log.info('clawd', `openclaw allowedOrigins 已配置: ${clawId}.claw.cutos.ai`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn('clawd', `openclaw 配置失败(可能未安装): ${e.message}`);
|
log.warn('clawd', `openclaw 配置失败: ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user