mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 06:33:18 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
83
openclaw/scripts/vitest-process-group.mjs
Normal file
83
openclaw/scripts/vitest-process-group.mjs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
export function shouldUseDetachedVitestProcessGroup(platform = process.platform) {
|
||||
return platform !== "win32";
|
||||
}
|
||||
|
||||
export function resolveVitestProcessGroupSignalTarget(params) {
|
||||
const pid = params.childPid;
|
||||
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) {
|
||||
return null;
|
||||
}
|
||||
return shouldUseDetachedVitestProcessGroup(params.platform) ? -pid : pid;
|
||||
}
|
||||
|
||||
export function forwardSignalToVitestProcessGroup(params) {
|
||||
const target = resolveVitestProcessGroupSignalTarget({
|
||||
childPid: params.child.pid,
|
||||
platform: params.platform,
|
||||
});
|
||||
if (target === null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
params.kill(target, params.signal);
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (
|
||||
error &&
|
||||
typeof error === "object" &&
|
||||
"code" in error &&
|
||||
(error.code === "ESRCH" || error.code === "EPERM")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function installVitestProcessGroupCleanup(params) {
|
||||
const processObject = params.processObject ?? process;
|
||||
const platform = params.platform ?? process.platform;
|
||||
const kill = params.kill ?? process.kill.bind(process);
|
||||
const cleanupSignal = params.cleanupSignal ?? "SIGTERM";
|
||||
const forwardedSignals = params.forwardedSignals ?? ["SIGINT", "SIGTERM"];
|
||||
const child = params.child;
|
||||
|
||||
let active = true;
|
||||
|
||||
const forward = (signal) => {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
forwardSignalToVitestProcessGroup({
|
||||
child,
|
||||
signal,
|
||||
platform,
|
||||
kill,
|
||||
});
|
||||
};
|
||||
|
||||
const signalHandlers = new Map();
|
||||
for (const signal of forwardedSignals) {
|
||||
const handler = () => {
|
||||
forward(signal);
|
||||
};
|
||||
signalHandlers.set(signal, handler);
|
||||
processObject.on(signal, handler);
|
||||
}
|
||||
|
||||
const exitHandler = () => {
|
||||
forward(cleanupSignal);
|
||||
};
|
||||
processObject.on("exit", exitHandler);
|
||||
|
||||
return () => {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
for (const [signal, handler] of signalHandlers) {
|
||||
processObject.off(signal, handler);
|
||||
}
|
||||
processObject.off("exit", exitHandler);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue