@gorlitzer-labs/seldon 0.1.16 → 0.1.17
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/bin/seldon.js +33 -3
- package/package.json +1 -1
package/bin/seldon.js
CHANGED
|
@@ -549,9 +549,39 @@ async function up() {
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
function down() {
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
552
|
+
const tracked = ["demerzel", "bonsai", "factory-watch"].filter((n) => stopDaemon(n));
|
|
553
|
+
// Belt-and-suspenders so nothing leaks: also reap by seldon's OWN ports and
|
|
554
|
+
// process signatures. This catches a server started outside seldon (manual
|
|
555
|
+
// launch) or a pidfile that drifted. Scoped tightly — only our ports and
|
|
556
|
+
// command shapes — so unrelated processes are never touched.
|
|
557
|
+
const probes = [
|
|
558
|
+
"lsof -nP -iTCP:8081 -sTCP:LISTEN -t", // bonsai llama-server
|
|
559
|
+
"lsof -nP -iTCP:8770 -sTCP:LISTEN -t", // voice UI
|
|
560
|
+
"lsof -nP -iTCP:8765 -sTCP:LISTEN -t", // voice websocket
|
|
561
|
+
`pgrep -f '${SELDON_HOME}/bonsai/bin/llama-server'`,
|
|
562
|
+
"pgrep -f 'demerzel[.]server'",
|
|
563
|
+
"pgrep -f 'factory.*watch --all'",
|
|
564
|
+
];
|
|
565
|
+
const collect = () => {
|
|
566
|
+
const s = new Set();
|
|
567
|
+
for (const c of probes) {
|
|
568
|
+
try { execSync(c, { stdio: ["ignore", "pipe", "ignore"] }).toString().split(/\s+/).filter(Boolean).forEach((p) => s.add(p)); } catch {}
|
|
569
|
+
}
|
|
570
|
+
s.delete(String(process.pid));
|
|
571
|
+
return [...s];
|
|
572
|
+
};
|
|
573
|
+
const first = collect();
|
|
574
|
+
for (const p of first) { try { process.kill(Number(p), "SIGTERM"); } catch {} }
|
|
575
|
+
let reaped = 0;
|
|
576
|
+
if (first.length) {
|
|
577
|
+
try { execSync("sleep 1.5"); } catch {}
|
|
578
|
+
for (const p of collect()) { try { process.kill(Number(p), "SIGKILL"); reaped++; } catch {} }
|
|
579
|
+
reaped = first.length; // count what we signalled
|
|
580
|
+
}
|
|
581
|
+
const parts = [];
|
|
582
|
+
if (tracked.length) parts.push("stopped " + tracked.join(", "));
|
|
583
|
+
if (first.length) parts.push(`reaped ${first.length} straggler${first.length > 1 ? "s" : ""}`);
|
|
584
|
+
console.log(parts.length ? C.green(parts.join(" · ")) : C.dim("nothing was running."));
|
|
555
585
|
}
|
|
556
586
|
|
|
557
587
|
// Version of a globally-installed node package, across pnpm / npm / bun roots.
|