tt-help-cli-ycl 1.4.57 → 1.4.59
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/watch/public/app.js
CHANGED
|
@@ -194,7 +194,7 @@ function renderStats() {
|
|
|
194
194
|
flashEl("statUserUpdateTasks", d.userUpdateTasks || 0, { full: true });
|
|
195
195
|
flashEl("statRawJobs", d.rawJobs || 0);
|
|
196
196
|
flashEl("statCommentTask", d.commentTaskCount || 0, { full: true });
|
|
197
|
-
flashEl("statTags", d.tagHighScore || 0);
|
|
197
|
+
flashEl("statTags", d.tagHighScore || 0, { full: true });
|
|
198
198
|
// 同步子页面 stats
|
|
199
199
|
const pendingTotal = document.getElementById("pendingStatTotal");
|
|
200
200
|
if (pendingTotal) pendingTotal.textContent = formatStatNum(d.totalUsers);
|
|
@@ -1361,6 +1361,10 @@ function navigateToSettings() {
|
|
|
1361
1361
|
// ========== LLM 配置页面 ==========
|
|
1362
1362
|
|
|
1363
1363
|
function hideAllPages() {
|
|
1364
|
+
if (_wdRefreshTimer) {
|
|
1365
|
+
clearInterval(_wdRefreshTimer);
|
|
1366
|
+
_wdRefreshTimer = null;
|
|
1367
|
+
}
|
|
1364
1368
|
document.getElementById("mainPage").classList.add("hidden");
|
|
1365
1369
|
document.getElementById("pendingPage").classList.remove("active");
|
|
1366
1370
|
document.getElementById("userUpdatePage").classList.remove("active");
|
|
@@ -3399,11 +3403,15 @@ function navigateToWatchdog() {
|
|
|
3399
3403
|
}
|
|
3400
3404
|
|
|
3401
3405
|
let _wdData = null;
|
|
3406
|
+
let _wdRefreshTimer = null;
|
|
3402
3407
|
|
|
3403
3408
|
function showWatchdogPage() {
|
|
3404
3409
|
hideAllPages();
|
|
3405
3410
|
document.getElementById("watchdogPage").classList.add("active");
|
|
3406
3411
|
fetchWatchdogData();
|
|
3412
|
+
// 每 10s 自动刷新
|
|
3413
|
+
if (_wdRefreshTimer) clearInterval(_wdRefreshTimer);
|
|
3414
|
+
_wdRefreshTimer = setInterval(fetchWatchdogData, 10000);
|
|
3407
3415
|
}
|
|
3408
3416
|
|
|
3409
3417
|
async function fetchWatchdogData() {
|
|
@@ -3487,16 +3495,7 @@ function renderWatchdogDashboard(clients, clientCommands) {
|
|
|
3487
3495
|
el.innerHTML = styled(
|
|
3488
3496
|
"div",
|
|
3489
3497
|
"color:#666;padding:30px;text-align:center",
|
|
3490
|
-
"
|
|
3491
|
-
tag(
|
|
3492
|
-
"button",
|
|
3493
|
-
{
|
|
3494
|
-
onclick: "fetchWatchdogData()",
|
|
3495
|
-
style:
|
|
3496
|
-
"margin-top:12px;padding:6px 14px;background:#60a5fa;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:12px",
|
|
3497
|
-
},
|
|
3498
|
-
"🔄 刷新",
|
|
3499
|
-
),
|
|
3498
|
+
"暂无客户端连接,等待看门狗上线...(每10秒自动刷新)",
|
|
3500
3499
|
);
|
|
3501
3500
|
return;
|
|
3502
3501
|
}
|
|
@@ -3507,24 +3506,14 @@ function renderWatchdogDashboard(clients, clientCommands) {
|
|
|
3507
3506
|
})
|
|
3508
3507
|
.join("");
|
|
3509
3508
|
|
|
3510
|
-
el.innerHTML =
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
"🔄 刷新",
|
|
3519
|
-
) +
|
|
3520
|
-
styled(
|
|
3521
|
-
"div",
|
|
3522
|
-
{
|
|
3523
|
-
style:
|
|
3524
|
-
"display:grid;grid-template-columns:repeat(auto-fill,minmax(440px,1fr));gap:16px",
|
|
3525
|
-
},
|
|
3526
|
-
cards,
|
|
3527
|
-
);
|
|
3509
|
+
el.innerHTML = styled(
|
|
3510
|
+
"div",
|
|
3511
|
+
{
|
|
3512
|
+
style:
|
|
3513
|
+
"display:grid;grid-template-columns:repeat(auto-fill,minmax(440px,1fr));gap:16px",
|
|
3514
|
+
},
|
|
3515
|
+
cards,
|
|
3516
|
+
);
|
|
3528
3517
|
}
|
|
3529
3518
|
|
|
3530
3519
|
function renderClientCard(c, clientCommands) {
|
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(
|
|
@@ -11,8 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
import { spawn, execSync } from "child_process";
|
|
13
13
|
import { EventEmitter } from "events";
|
|
14
|
+
import os from "os";
|
|
14
15
|
|
|
15
16
|
const MAX_RESTART = 3;
|
|
17
|
+
const SHELL =
|
|
18
|
+
os.platform() === "win32"
|
|
19
|
+
? { cmd: process.env.COMSPEC || "cmd.exe", flag: "/c" }
|
|
20
|
+
: { cmd: "sh", flag: "-c" };
|
|
16
21
|
|
|
17
22
|
function getProcessStats(pid) {
|
|
18
23
|
try {
|
|
@@ -67,7 +72,7 @@ export class ProcessManager extends EventEmitter {
|
|
|
67
72
|
detached: false,
|
|
68
73
|
});
|
|
69
74
|
} else {
|
|
70
|
-
child = spawn(
|
|
75
|
+
child = spawn(SHELL.cmd, [SHELL.flag, command], {
|
|
71
76
|
stdio: ["ignore", "pipe", "pipe"],
|
|
72
77
|
detached: false,
|
|
73
78
|
});
|
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
|
|