mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 09:10:22 +08:00
fix(web): boot 前回收 detached 残留 server,修 EADDRINUSE 起不来 (#197)
- restart-web.js 把后台 server 的 pid/url 记到 \/dsh-purge/web-server-<port>.json - killOldServer 增加按端口兜底:清掉旧版本留下、没有 pid 记录的孤儿 - 新增 lib/bin-preflight.js:把回收钩子注入宿主 bin.js 顶部,早于 Cordis 激活与 webserver 绑端口 - 重启时打印『后台运行、关窗不会停』,避免把提示符返回误判成程序已退出 - 新增 test/web-reclaim.test.js(7 例),全量 node --test 91/91 通过
This commit is contained in:
1 parent
53dd6c2f84
commit
5a112b4bdc
7 files changed
+544
-10
No files matched your search
+20
-3
@@ -11,6 +11,7 @@ import {
|
||||
resolveDshBinRoot,
|
||||
revertHideConsoleFromBin,
|
||||
} from "./hide-console.js";
|
||||
import { installBinPreflight, revertBinPreflight } from "./bin-preflight.js";
|
||||
import * as desktop from "./desktop.js";
|
||||
import {
|
||||
asarArchiveIsFile,
|
||||
@@ -400,7 +401,14 @@ export function ensureHiddenConsole(aiBase = findAiBase()) {
|
||||
} catch (e) {
|
||||
entry = `error:${e && e.message ? e.message : e}`;
|
||||
}
|
||||
return { live, entry, entryRoot };
|
||||
// #197:web 重启后的孤儿 server 要在 Cordis 激活前回收,钩子必须早于 webserver 绑端口。
|
||||
let preflight = "unknown";
|
||||
try {
|
||||
preflight = installBinPreflight(entryRoot || aiBase);
|
||||
} catch (e) {
|
||||
preflight = `error:${e && e.message ? e.message : e}`;
|
||||
}
|
||||
return { live, entry, preflight, entryRoot };
|
||||
}
|
||||
|
||||
export function silenceCmdFlash(aiBase = findAiBase()) {
|
||||
@@ -429,6 +437,9 @@ export function silenceCmdFlash(aiBase = findAiBase()) {
|
||||
liangshenPrompt === "already" ||
|
||||
liangshenPrompt === "patched" ||
|
||||
liangshenPrompt === "pattern_miss";
|
||||
const preflightOk =
|
||||
["injected", "already_injected", "skipped_source_cli", "missing_bin", "sealed_asar"].includes(hide.preflight) ||
|
||||
(typeof hide.preflight === "string" && hide.preflight.startsWith("error:"));
|
||||
return {
|
||||
...hide,
|
||||
doctor,
|
||||
@@ -440,7 +451,7 @@ export function silenceCmdFlash(aiBase = findAiBase()) {
|
||||
officialPhase1,
|
||||
liangshenPrompt,
|
||||
mnemon,
|
||||
ok: hideOk && liangshenOk,
|
||||
ok: hideOk && liangshenOk && preflightOk,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -582,7 +593,13 @@ export function revertCmdFlash(aiBase = findAiBase(), dshHome = findDshHome()) {
|
||||
if (next.includes(importReplacement)) next = next.replace(importReplacement, importNeedle);
|
||||
return next;
|
||||
});
|
||||
return { hide, subprocess, customBash, phase1, doctorSpawn, market };
|
||||
let preflight = "absent";
|
||||
try {
|
||||
preflight = revertBinPreflight(aiBase);
|
||||
} catch (e) {
|
||||
preflight = `error:${e && e.message ? e.message : e}`;
|
||||
}
|
||||
return { hide, preflight, subprocess, customBash, phase1, doctorSpawn, market };
|
||||
}
|
||||
|
||||
export function silenceSubprocessLocalFlash(dshHome = findDshHome()) {
|
||||
|
||||
Reference in new issue
Block a user