@ryantest/openclaw-qqbot 1.6.7-beta.20 → 1.6.7-beta.21
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/dist/src/slash-commands.js +25 -3
- package/package.json +1 -1
- package/src/slash-commands.ts +23 -3
|
@@ -793,10 +793,15 @@ function fireHotUpgrade(targetVersion, pkg, useLocal) {
|
|
|
793
793
|
// 必须显式设置 cwd 为一个确定存在的目录(如 homeDir),
|
|
794
794
|
// 否则子进程继承 gateway 的 cwd,如果该目录在升级过程中被删除/移动,
|
|
795
795
|
// openclaw CLI 启动时 process.cwd() 会报 ENOENT: uv_cwd 错误。
|
|
796
|
-
|
|
797
|
-
|
|
796
|
+
// 超时设为 5 分钟:openclaw plugins install 需要下载 npm 包,
|
|
797
|
+
// 网络慢时(如国内访问 npm registry)可能需要 2-3 分钟。
|
|
798
|
+
// 120 秒超时会导致脚本被杀但 openclaw CLI 子进程继续运行,
|
|
799
|
+
// 同时 bash 的 cleanup_on_exit 回滚了备份目录,造成 "plugin already exists" 错误。
|
|
800
|
+
const child = execFile(shell, shellArgs, {
|
|
801
|
+
timeout: 300_000,
|
|
798
802
|
cwd: homeDir,
|
|
799
803
|
env: childEnv,
|
|
804
|
+
killSignal: "SIGTERM",
|
|
800
805
|
...(isWindows() ? { windowsHide: true } : {}),
|
|
801
806
|
}, (error, stdout, _stderr) => {
|
|
802
807
|
if (error) {
|
|
@@ -805,6 +810,24 @@ function fireHotUpgrade(targetVersion, pkg, useLocal) {
|
|
|
805
810
|
console.error(`[qqbot] fireHotUpgrade: stdout: ${stdout.slice(0, 2000)}`);
|
|
806
811
|
if (_stderr)
|
|
807
812
|
console.error(`[qqbot] fireHotUpgrade: stderr: ${_stderr.slice(0, 2000)}`);
|
|
813
|
+
// 超时时确保子进程树被清理,防止 openclaw plugins install 继续运行
|
|
814
|
+
// 与 cleanup_on_exit 的回滚逻辑冲突(回滚恢复了旧目录,install 又尝试写入)
|
|
815
|
+
if (error.killed || error.message.includes("TIMEOUT")) {
|
|
816
|
+
try {
|
|
817
|
+
// 尝试杀掉子进程树(SIGKILL 确保立即终止)
|
|
818
|
+
child.kill("SIGKILL");
|
|
819
|
+
// 额外尝试通过 pkill 杀掉可能残留的 openclaw plugins install 子进程
|
|
820
|
+
if (!isWindows()) {
|
|
821
|
+
try {
|
|
822
|
+
execFileSync("pkill", ["-9", "-f", "openclaw.*plugins.*install"], { timeout: 3000, stdio: "pipe" });
|
|
823
|
+
}
|
|
824
|
+
catch { /* ignore */ }
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
catch {
|
|
828
|
+
// 进程可能已退出
|
|
829
|
+
}
|
|
830
|
+
}
|
|
808
831
|
syncTempConfigAndCleanup();
|
|
809
832
|
cleanupTempScript();
|
|
810
833
|
_upgrading = false;
|
|
@@ -991,7 +1014,6 @@ elif [ -f "$BACKUP" ]; then
|
|
|
991
1014
|
# gateway 的 config file watcher 会检测到变更并热加载
|
|
992
1015
|
echo "[qqbot-upgrade] Restoring channels.qqbot to real config..."
|
|
993
1016
|
node -e "
|
|
994
|
-
const fs = require('fs');
|
|
995
1017
|
const fs = require('fs');
|
|
996
1018
|
const cfg = JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));
|
|
997
1019
|
const qqbot = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
|
package/package.json
CHANGED
package/src/slash-commands.ts
CHANGED
|
@@ -891,16 +891,37 @@ function fireHotUpgrade(targetVersion?: string, pkg?: string, useLocal?: boolean
|
|
|
891
891
|
// 必须显式设置 cwd 为一个确定存在的目录(如 homeDir),
|
|
892
892
|
// 否则子进程继承 gateway 的 cwd,如果该目录在升级过程中被删除/移动,
|
|
893
893
|
// openclaw CLI 启动时 process.cwd() 会报 ENOENT: uv_cwd 错误。
|
|
894
|
-
|
|
895
|
-
|
|
894
|
+
// 超时设为 5 分钟:openclaw plugins install 需要下载 npm 包,
|
|
895
|
+
// 网络慢时(如国内访问 npm registry)可能需要 2-3 分钟。
|
|
896
|
+
// 120 秒超时会导致脚本被杀但 openclaw CLI 子进程继续运行,
|
|
897
|
+
// 同时 bash 的 cleanup_on_exit 回滚了备份目录,造成 "plugin already exists" 错误。
|
|
898
|
+
const child = execFile(shell, shellArgs, {
|
|
899
|
+
timeout: 300_000,
|
|
896
900
|
cwd: homeDir,
|
|
897
901
|
env: childEnv,
|
|
902
|
+
killSignal: "SIGTERM",
|
|
898
903
|
...(isWindows() ? { windowsHide: true } : {}),
|
|
899
904
|
}, (error, stdout, _stderr) => {
|
|
900
905
|
if (error) {
|
|
901
906
|
console.error(`[qqbot] fireHotUpgrade: script failed: ${error.message}`);
|
|
902
907
|
if (stdout) console.error(`[qqbot] fireHotUpgrade: stdout: ${stdout.slice(0, 2000)}`);
|
|
903
908
|
if (_stderr) console.error(`[qqbot] fireHotUpgrade: stderr: ${_stderr.slice(0, 2000)}`);
|
|
909
|
+
|
|
910
|
+
// 超时时确保子进程树被清理,防止 openclaw plugins install 继续运行
|
|
911
|
+
// 与 cleanup_on_exit 的回滚逻辑冲突(回滚恢复了旧目录,install 又尝试写入)
|
|
912
|
+
if ((error as any).killed || error.message.includes("TIMEOUT")) {
|
|
913
|
+
try {
|
|
914
|
+
// 尝试杀掉子进程树(SIGKILL 确保立即终止)
|
|
915
|
+
child.kill("SIGKILL");
|
|
916
|
+
// 额外尝试通过 pkill 杀掉可能残留的 openclaw plugins install 子进程
|
|
917
|
+
if (!isWindows()) {
|
|
918
|
+
try { execFileSync("pkill", ["-9", "-f", "openclaw.*plugins.*install"], { timeout: 3000, stdio: "pipe" }); } catch { /* ignore */ }
|
|
919
|
+
}
|
|
920
|
+
} catch {
|
|
921
|
+
// 进程可能已退出
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
904
925
|
syncTempConfigAndCleanup();
|
|
905
926
|
cleanupTempScript();
|
|
906
927
|
_upgrading = false;
|
|
@@ -1092,7 +1113,6 @@ elif [ -f "$BACKUP" ]; then
|
|
|
1092
1113
|
# gateway 的 config file watcher 会检测到变更并热加载
|
|
1093
1114
|
echo "[qqbot-upgrade] Restoring channels.qqbot to real config..."
|
|
1094
1115
|
node -e "
|
|
1095
|
-
const fs = require('fs');
|
|
1096
1116
|
const fs = require('fs');
|
|
1097
1117
|
const cfg = JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));
|
|
1098
1118
|
const qqbot = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
|