openclawsetup 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +42 -3
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1010,6 +1010,8 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1010
1010
|
console.log(colors.yellow(' 尝试启动 Gateway...'));
|
|
1011
1011
|
const startResult = safeExec(`${cliName} gateway start`);
|
|
1012
1012
|
if (startResult.ok) {
|
|
1013
|
+
console.log(colors.gray(' 等待 Gateway 启动...'));
|
|
1014
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
1013
1015
|
log.success('Gateway 已启动');
|
|
1014
1016
|
fixed.push('Gateway 已自动启动');
|
|
1015
1017
|
} else {
|
|
@@ -1040,7 +1042,10 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1040
1042
|
log.success(`端口 ${port} 正在监听`);
|
|
1041
1043
|
} else {
|
|
1042
1044
|
// 检查是否有其他进程占用端口
|
|
1043
|
-
const
|
|
1045
|
+
const conflictCmd = platform() === 'win32'
|
|
1046
|
+
? `netstat -ano | findstr :${port} | findstr LISTENING`
|
|
1047
|
+
: `lsof -i :${port} 2>/dev/null | head -5`;
|
|
1048
|
+
const conflictCheck = safeExec(conflictCmd);
|
|
1044
1049
|
if (conflictCheck.ok && conflictCheck.output && !conflictCheck.output.includes('openclaw') && !conflictCheck.output.includes('node')) {
|
|
1045
1050
|
const issue = {
|
|
1046
1051
|
level: 'error',
|
|
@@ -1074,8 +1079,18 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1074
1079
|
console.log(colors.yellow(' 尝试重启 Gateway...'));
|
|
1075
1080
|
const restartResult = safeExec(`${cliName} gateway restart`);
|
|
1076
1081
|
if (restartResult.ok) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1082
|
+
// 等待 Gateway 绑定端口
|
|
1083
|
+
console.log(colors.gray(' 等待 Gateway 启动...'));
|
|
1084
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
1085
|
+
// 重新检查端口
|
|
1086
|
+
const recheck = safeExec(portCheckCmd);
|
|
1087
|
+
if (recheck.ok && recheck.output) {
|
|
1088
|
+
log.success('Gateway 已重启,端口正常');
|
|
1089
|
+
fixed.push('Gateway 已自动重启');
|
|
1090
|
+
} else {
|
|
1091
|
+
log.warn('Gateway 已重启但端口仍未监听');
|
|
1092
|
+
issues.push({ ...issue, detail: 'Gateway 重启后端口仍未监听,可能配置有问题' });
|
|
1093
|
+
}
|
|
1079
1094
|
} else {
|
|
1080
1095
|
issues.push(issue);
|
|
1081
1096
|
}
|
|
@@ -1120,6 +1135,8 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1120
1135
|
console.log(colors.yellow(' 尝试重启 Gateway...'));
|
|
1121
1136
|
const restartResult = safeExec(`${cliName} gateway restart`);
|
|
1122
1137
|
if (restartResult.ok) {
|
|
1138
|
+
console.log(colors.gray(' 等待 Gateway 启动...'));
|
|
1139
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
1123
1140
|
log.success('Gateway 已重启');
|
|
1124
1141
|
fixed.push('Gateway 已自动重启(API 无响应)');
|
|
1125
1142
|
} else {
|
|
@@ -1501,6 +1518,28 @@ function askQuestion(prompt) {
|
|
|
1501
1518
|
async function main() {
|
|
1502
1519
|
const options = parseArgs();
|
|
1503
1520
|
|
|
1521
|
+
// 检查是否为最新版本,提示用户更新
|
|
1522
|
+
try {
|
|
1523
|
+
const pkgJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1524
|
+
const currentVersion = pkgJson.version;
|
|
1525
|
+
const latestResult = safeExec('npm view openclawsetup version 2>/dev/null');
|
|
1526
|
+
if (latestResult.ok && latestResult.output) {
|
|
1527
|
+
const latestVersion = latestResult.output.trim();
|
|
1528
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
1529
|
+
console.log(colors.yellow(`\n⚠ 当前版本 ${currentVersion},最新版本 ${latestVersion}`));
|
|
1530
|
+
console.log(colors.yellow(' 正在更新到最新版本...\n'));
|
|
1531
|
+
const updateCmd = platform() === 'win32'
|
|
1532
|
+
? `npx --yes openclawsetup@${latestVersion}`
|
|
1533
|
+
: `npx --yes openclawsetup@${latestVersion}`;
|
|
1534
|
+
spawnSync(updateCmd.split(' ')[0], updateCmd.split(' ').slice(1), {
|
|
1535
|
+
stdio: 'inherit',
|
|
1536
|
+
shell: true,
|
|
1537
|
+
});
|
|
1538
|
+
process.exit(0);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
} catch { /* ignore version check errors */ }
|
|
1542
|
+
|
|
1504
1543
|
if (options.help) {
|
|
1505
1544
|
showHelp();
|
|
1506
1545
|
process.exit(0);
|