Files
ps5upload/scripts/stale-client-lib.mjs
T
phantomptrandClaude Opus 5.5 0bba2cbab8 fix(scripts): make run-client stops only the engine on the app's port
kill-stale-client did `pkill -f ps5upload-engine`, which SIGTERMed
every engine on the machine — a standalone one on another port died 70
minutes into a package build. It now stops only an engine listening on
19113 (an engine whose app is gone exits by itself). The decision is a
small pure module with node:test cases, which scripts:check now runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 12:23:54 -07:00

22 lines
1008 B
JavaScript

// What `make run-client` may clean up before starting the dev app (see kill-stale-client.mjs).
//
// Only an engine holding the desktop app's own port is stale. A blanket
// `pkill -f ps5upload-engine` also killed engines that had nothing to do with the
// dev app — a standalone one on another port running a 70-minute conversion
// died mid-build. An engine whose app is gone exits by itself (its parent watch),
// so the port holder is the only one that can be in the way.
/** The engine's port the desktop app binds first. */
export const APP_ENGINE_PORT = 19113;
/** The executable is the engine itself, not a command that merely mentions it. */
function isEngine(command) {
const exe = command.trim().split(/\s+(?=-)/)[0];
return /(^|[\\/])ps5upload-engine(\.exe)?$/i.test(exe);
}
/** Of the processes listening on the app's port, the pids that are a ps5upload engine. */
export function staleEnginePids(listeners) {
return listeners.filter((l) => isEngine(l.command)).map((l) => l.pid);
}