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 配置 ────────────────────────────────────────────────────────────
|
||||
|
||||
_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 {
|
||||
const origins = JSON.stringify([
|
||||
'http://0.0.0.0:18789',
|
||||
`https://${clawId}.claw.cutos.ai`,
|
||||
]);
|
||||
execFileSync('openclaw', ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], {
|
||||
execFileSync(bin, ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], {
|
||||
timeout: 5000,
|
||||
stdio: 'ignore',
|
||||
});
|
||||
log.info('clawd', `openclaw allowedOrigins 已配置: ${clawId}.claw.cutos.ai`);
|
||||
} catch (e) {
|
||||
log.warn('clawd', `openclaw 配置失败(可能未安装): ${e.message}`);
|
||||
log.warn('clawd', `openclaw 配置失败: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user