cicy-desktop 2.1.315 → 2.1.316
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
|
@@ -277,6 +277,14 @@ function register({ sidecarLogPath } = {}) {
|
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
if (_relayMisses < 2) { log.warn(`[docker-daemon] :${APP_PORT} unreachable from Windows but healthy inside (${_relayMisses}/2)`); return; }
|
|
280
|
+
// 已重置过一次仍不通:bootstrap 对此无能为力(而且以前它会跑「修复=更新」把 cicy-code
|
|
281
|
+
// 重启掉)。只把原因和修复提示写进卡片,每 10 分钟记一次日志,不再反复 bootstrap。
|
|
282
|
+
if (_relayResetDone) {
|
|
283
|
+
const hint = (appDocker.RELAY_UNREACHABLE_HINT && appDocker.RELAY_UNREACHABLE_HINT(APP_PORT)) || `container healthy inside but 127.0.0.1:${APP_PORT} unreachable from Windows`;
|
|
284
|
+
if (!_lastBootstrapError || _lastBootstrapError.reason !== "relay_unreachable") { _lastBootstrapError = { reason: "relay_unreachable", message: hint, ts: Date.now() }; log.warn(`[docker-daemon] ${hint}`); }
|
|
285
|
+
await refreshDockerStatus();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
280
288
|
} else { _relayMisses = 0; }
|
|
281
289
|
} else if (s.running) { _relayMisses = 0; }
|
|
282
290
|
if (!s.running && !s.unknown && _autoBootstrapPaused && Date.now() < _autoBootstrapRetryAt) {
|
|
@@ -656,6 +656,13 @@ async function ensureFreshImage({ emit } = {}) {
|
|
|
656
656
|
// 容器内部视角的健康:docker exec 进容器用 node 探 127.0.0.1:8008。用来区分「容器真挂了」和
|
|
657
657
|
// 「容器好好的、只是 WSL 的 localhost 转发坏了」(后者 Windows 侧 :8008 打不通,实测
|
|
658
658
|
// `wsl --shutdown` 后 75 秒恢复)。
|
|
659
|
+
// 容器内健康、Windows 却连不上 :port 时给用户/日志的统一说明(bootstrap 与守护循环共用)。
|
|
660
|
+
function RELAY_UNREACHABLE_HINT(port = 8008) {
|
|
661
|
+
return `容器内 cicy-code 正常,但 Windows 连不上 127.0.0.1:${port}(WSL localhost 转发或 Windows TCP 端口异常;` +
|
|
662
|
+
`若桌面端日志里出现 connect EADDRINUSE,多半是 Windows 动态端口被占满/被 Hyper-V 保留段吞掉)。` +
|
|
663
|
+
`已自动重置过一次 WSL 仍不通时,请在管理员 PowerShell 执行:` +
|
|
664
|
+
` netsh int ipv4 show excludedportrange protocol=tcp; netsh int ipv4 set dynamicport tcp start=49152 num=16384; 然后重启 Windows。`;
|
|
665
|
+
}
|
|
659
666
|
async function insideHealthy(container = "cicy-code-docker-8008", port = 8008) {
|
|
660
667
|
try {
|
|
661
668
|
await wslRun(`docker exec ${container} node -e "fetch('http://127.0.0.1:${port}/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"`, { timeout: 20000 });
|
|
@@ -1374,7 +1381,17 @@ async function _bootstrap({ onProgress, port = 8008, container = "cicy-code-dock
|
|
|
1374
1381
|
if (!healthy && !protect.guard(log, "auto-update after health miss")) {
|
|
1375
1382
|
healthy = await docker.waitUntil(() => probeHealth(port), { totalMs: 120000, everyMs: 3000 }); // 保护开启:只等,不自动改容器
|
|
1376
1383
|
}
|
|
1384
|
+
// Windows 侧探不到 ≠ 容器坏了。先从容器内部探一次:内部健康 = WSL localhost 转发 / Windows 端口
|
|
1385
|
+
// 出了问题(实测 connect EADDRINUSE 连外网也报),这时绝不能再跑 update()「修复」——它会
|
|
1386
|
+
// SIGTERM 重启 cicy-code,把正在跑的 agent 全部打断,而且对转发问题毫无帮助。
|
|
1387
|
+
let relayBroken = false;
|
|
1377
1388
|
if (!healthy) {
|
|
1389
|
+
try { relayBroken = await insideHealthy(container, port); } catch {}
|
|
1390
|
+
}
|
|
1391
|
+
if (!healthy && relayBroken) {
|
|
1392
|
+
log.warn(`[bootstrap] container healthy inside but 127.0.0.1:${port} unreachable from Windows → not touching the container`);
|
|
1393
|
+
emit({ phase: "container", status: "running", message: RELAY_UNREACHABLE_HINT(port) });
|
|
1394
|
+
} else if (!healthy) {
|
|
1378
1395
|
emit({ phase: "container", status: "running", message: "服务尚未响应,正在检查并修复运行时完整性…" });
|
|
1379
1396
|
try {
|
|
1380
1397
|
const repaired = await update({ onProgress: emit, container, port });
|
|
@@ -1383,11 +1400,13 @@ async function _bootstrap({ onProgress, port = 8008, container = "cicy-code-dock
|
|
|
1383
1400
|
log.warn(`[bootstrap] runtime auto-repair failed: ${e.message}`);
|
|
1384
1401
|
}
|
|
1385
1402
|
}
|
|
1386
|
-
if (!healthy) healthy = await docker.waitUntil(() => probeHealth(port), { totalMs: 105000, everyMs: 3000 });
|
|
1403
|
+
if (!healthy) healthy = await docker.waitUntil(() => probeHealth(port), { totalMs: relayBroken ? 30000 : 105000, everyMs: 3000 });
|
|
1387
1404
|
if (healthy) { done(); await ensureAutostart(); await ensureDesktopShortcut(volume, port); } // survive reboot + desktop shortcut
|
|
1388
|
-
else fail("health_timeout");
|
|
1405
|
+
else fail(relayBroken ? "relay_unreachable" : "health_timeout", relayBroken ? RELAY_UNREACHABLE_HINT(port) : "");
|
|
1389
1406
|
let healthMessage = "Docker cicy-code 已就绪 🎉";
|
|
1390
|
-
if (!healthy) {
|
|
1407
|
+
if (!healthy && relayBroken) {
|
|
1408
|
+
healthMessage = RELAY_UNREACHABLE_HINT(port);
|
|
1409
|
+
} else if (!healthy) {
|
|
1391
1410
|
let tail = "";
|
|
1392
1411
|
try {
|
|
1393
1412
|
const r = await wslRun(`docker logs --tail 60 ${container}`, { timeout: 15000 });
|
|
@@ -1473,7 +1492,10 @@ async function cicyRuntimePlatformReady(container) {
|
|
|
1473
1492
|
const check = `target=$(readlink -f "$HOME/.local/bin/cicy-code" 2>/dev/null || true); ` +
|
|
1474
1493
|
`dest=$(dirname "$(dirname "$target")" 2>/dev/null); ` +
|
|
1475
1494
|
`case "$(uname -m)" in x86_64) p=cicy-code-linux-x64;; aarch64|arm64) p=cicy-code-linux-arm64;; *) exit 1;; esac; ` +
|
|
1476
|
-
|
|
1495
|
+
// readlink -f 会一路解析到 <prefix>/lib/node_modules/cicy-code/bin/cicy-code.js,此时 $dest 就是
|
|
1496
|
+
// 包目录本身,平台包在 $dest/node_modules/<p>(实际布局)。之前只查 $dest/lib/... 两种 → 永远 false
|
|
1497
|
+
// → 每轮 bootstrap 都把「更新 cicy-code」当修复跑一遍 → 更新脚本 SIGTERM 重启 cicy-code,打断所有 agent。
|
|
1498
|
+
`[ -x "$target" ] && { [ -f "$dest/node_modules/$p/package.json" ] || [ -f "$dest/lib/node_modules/$p/package.json" ] || [ -f "$dest/lib/node_modules/cicy-code/node_modules/$p/package.json" ]; }`;
|
|
1477
1499
|
try { await wslRun(`docker exec ${container} bash -lc '${check}'`, { timeout: 15000 }); return true; }
|
|
1478
1500
|
catch { return false; }
|
|
1479
1501
|
}
|
|
@@ -1685,7 +1707,7 @@ async function readMihomoSelections(container = "cicy-code-docker-8008") {
|
|
|
1685
1707
|
}
|
|
1686
1708
|
|
|
1687
1709
|
module.exports = {
|
|
1688
|
-
insideHealthy, wslShutdown,
|
|
1710
|
+
insideHealthy, wslShutdown, RELAY_UNREACHABLE_HINT,
|
|
1689
1711
|
bootstrap, status, restart, stop, dockerRestart, recreate, update, upgrade, runContainer, readContainerToken,
|
|
1690
1712
|
distroInstalled, dockerInstalled, dockerEngineUp, imagePresent, probeHealth, wslRun, hasGatewayKey,
|
|
1691
1713
|
readMihomoConfig, readMihomoSelections, parseMihomoSelections,
|
|
@@ -10,3 +10,26 @@ test("does not skip an update when the recorded version matches but the platform
|
|
|
10
10
|
test("skips an update only when the recorded version matches and the runtime is complete", () => {
|
|
11
11
|
assert.equal(shouldSkipCicyUpdate({ latest: "2.3.563", current: "2.3.563", platformReady: true }), true);
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
const fs = require("node:fs");
|
|
15
|
+
const path = require("node:path");
|
|
16
|
+
const readSrc = (p) => fs.readFileSync(path.join(__dirname, "..", p), "utf8");
|
|
17
|
+
|
|
18
|
+
test("platform-ready check covers the real npm layout (<pkg>/node_modules/cicy-code-linux-x64)", () => {
|
|
19
|
+
const src = readSrc("src/sidecar/wsl-docker.js");
|
|
20
|
+
assert.match(src, /\[ -f "\$dest\/node_modules\/\$p\/package\.json" \]/);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("bootstrap never runs the updater when the container is healthy inside (relay problem)", () => {
|
|
24
|
+
const src = readSrc("src/sidecar/wsl-docker.js");
|
|
25
|
+
const i = src.indexOf('begin("wait-health")');
|
|
26
|
+
const block = src.slice(i, i + 3500);
|
|
27
|
+
assert.match(block, /relayBroken = await insideHealthy\(container, port\)/);
|
|
28
|
+
assert.match(block, /else if \(!healthy\) \{[\s\S]*?await update\(/);
|
|
29
|
+
assert.match(block, /fail\(relayBroken \? "relay_unreachable" : "health_timeout"/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("daemon loop stops re-bootstrapping after the one-shot relay reset", () => {
|
|
33
|
+
const src = readSrc("src/backends/sidecar-ipc.js");
|
|
34
|
+
assert.match(src, /if \(_relayResetDone\) \{[\s\S]*?reason: "relay_unreachable"[\s\S]*?return;/);
|
|
35
|
+
});
|