cloud / scripts / cloud-rehearsal / stop.tsmain at aacbc74
// stop.ts — ends one rehearsal's server and tunnel: `node scripts/cloud-rehearsal/stop.ts fake-cf-<time>`.
// The run's folder stays, and so does the rehearsal in the mind: they are the record. README.md,
// "Removing a rehearsal from a mind", says how to take the mind's part away.
import { readFileSync } from "node:fs";
import { join } from "node:path";
const id = process.argv[2];
if (!id || !/^fake-cf-\d+$/.test(id)) throw new Error("usage: node stop.ts fake-cf-<time>");
const pids: Record<string, number> = JSON.parse(
readFileSync(join(import.meta.dirname, "runs.ignoreme", id, "pids.json"), "utf8"),
);
for (const [name, pid] of Object.entries(pids)) {
try {
process.kill(pid, "SIGTERM");
console.log(`Stopped the ${name} (${pid}).`);
} catch {
console.log(`The ${name} (${pid}) was not running.`);
}
}