openclaw/scripts/lib/gateway-bench-stop-preload.mjs
Peter Steinberger 224821e68d
feat(ci): measure installed Gateway startup on Windows (#151635)
* feat(ci): measure installed Gateway startup on Windows

* fix(ci): prepare pinned pnpm on Windows with selected Node

* test(perf): exercise surviving Windows benchmark descendants

* fix(ci): retain resolved startup package metadata
2026-09-18 03:08:47 -07:00

32 lines
950 B
JavaScript

// The benchmark owns this IPC channel; Gateway's existing SIGINT handler owns cleanup.
const owner = new URL(import.meta.url);
if (
process.send &&
process.ppid === Number(owner.searchParams.get("parentPid")) &&
process.argv[1] === owner.searchParams.get("entry")
) {
process.on("message", function stop(message) {
if (message !== "openclaw-startup-benchmark:stop") {
return;
}
process.off("message", stop);
process.channel?.ref();
const accepted = process.listenerCount("SIGINT") > 0;
void import("node:module").then(({ getCompileCacheDir }) => {
process.send(
{
type: "openclaw-startup-benchmark:stopping",
accepted,
compileCacheDir: getCompileCacheDir() ?? null,
},
() => {
process.channel?.unref();
if (accepted) {
process.emit("SIGINT");
}
},
);
});
});
process.channel?.unref();
}