stopProcess
uses process
Stop one of the tcms running on the studio's codebase (tcm dev, start, serve: one its records name, by its
process), as Ctrl-C would. Only for the studio's maintainer; never the studio itself, or a process the records
don't name.
import { liveRunning } from "#codebase/tcmts/cli/running"; import { shareNow } from "#codebase/tcmts/share"; export async function stopProcess(pid: number): Promise<string> { const s = shareNow(); if (s.caller.role !== "maintainer") throw new Error("only the studio's maintainer stops what's running"); const r = liveRunning(s.cb.lay.root).find((x) => x.pid === pid); if (!r) throw new Error(`no tcm with process ${pid} is running on this codebase`); if (r.command === "studio" || r.pid === process.pid || r.pid === process.ppid) throw new Error("the studio doesn't stop itself: stop tcm studio where it runs"); process.kill(pid, "SIGINT"); return `stopped tcm ${r.command}${r.app ? ` ${r.app}` : ""}`; }