tt-help-cli-ycl 1.4.58 → 1.4.60
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/package.json
CHANGED
package/src/watchdog/agent.js
CHANGED
|
@@ -35,6 +35,9 @@ export class WatchdogAgent {
|
|
|
35
35
|
this.maxFailures = 10;
|
|
36
36
|
this.upgradeChecker = null;
|
|
37
37
|
this.ttHelpVersion = getVersion();
|
|
38
|
+
this._heartbeatSeq = 0; // 心跳序号
|
|
39
|
+
this._lastProcCount = -1; // 上次进程数
|
|
40
|
+
this._lastCmdCount = -1; // 上次命令数
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
@@ -156,10 +159,19 @@ export class WatchdogAgent {
|
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
// 心跳日志:仅状态变化或每 10 次打印一次
|
|
163
|
+
this._heartbeatSeq++;
|
|
164
|
+
const cmdCount = data.commands?.length || 0;
|
|
165
|
+
const changed =
|
|
166
|
+
procCount !== this._lastProcCount || cmdCount !== this._lastCmdCount;
|
|
167
|
+
if (changed || this._heartbeatSeq % 10 === 1) {
|
|
168
|
+
const ts = new Date().toLocaleTimeString("zh-CN", { hour12: false });
|
|
169
|
+
console.error(
|
|
170
|
+
`[watchdog ${ts}] 心跳 OK (${procCount}进程, ${cmdCount}条)`,
|
|
171
|
+
);
|
|
172
|
+
this._lastProcCount = procCount;
|
|
173
|
+
this._lastCmdCount = cmdCount;
|
|
174
|
+
}
|
|
163
175
|
} catch (e) {
|
|
164
176
|
this.consecutiveFailures++;
|
|
165
177
|
console.error(
|
|
@@ -60,16 +60,17 @@ export class ProcessManager extends EventEmitter {
|
|
|
60
60
|
let child;
|
|
61
61
|
const startTime = Date.now();
|
|
62
62
|
try {
|
|
63
|
-
// 有显式 args 则直接 spawn,否则用
|
|
63
|
+
// 有显式 args 则直接 spawn,否则用 shell 模式传递完整命令行(跨平台兼容)
|
|
64
64
|
if (args.length > 0) {
|
|
65
65
|
child = spawn(command, args, {
|
|
66
66
|
stdio: ["ignore", "pipe", "pipe"],
|
|
67
67
|
detached: false,
|
|
68
68
|
});
|
|
69
69
|
} else {
|
|
70
|
-
child = spawn(
|
|
70
|
+
child = spawn(command, {
|
|
71
71
|
stdio: ["ignore", "pipe", "pipe"],
|
|
72
72
|
detached: false,
|
|
73
|
+
shell: true,
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
} catch (e) {
|
package/src/watchdog/upgrader.js
CHANGED
|
@@ -26,9 +26,11 @@ export function getVersion() {
|
|
|
26
26
|
|
|
27
27
|
/** 是否通过全局 npm 安装运行 */
|
|
28
28
|
export function isGlobalInstall() {
|
|
29
|
-
const entry = process.argv[1] || "";
|
|
29
|
+
const entry = (process.argv[1] || "").replace(/\\/g, "/");
|
|
30
30
|
return (
|
|
31
|
-
entry.includes(`/node_modules/${PACKAGE}/`) ||
|
|
31
|
+
entry.includes(`/node_modules/${PACKAGE}/`) ||
|
|
32
|
+
entry.endsWith("/tt-help") ||
|
|
33
|
+
entry.endsWith("/tt-help.cmd")
|
|
32
34
|
);
|
|
33
35
|
}
|
|
34
36
|
|