MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / down

Function down

e2e/scripts/cli.ts:511–539  ·  view source on GitHub ↗
(targetName: string)

Source from the content-addressed store, hash-verified

509};
510
511const down = async (targetName: string) => {
512 const state = readState(targetName);
513 if (!state) return console.log(`${targetName}: nothing recorded`);
514 if (alive(state.runnerPid)) {
515 process.kill(state.runnerPid, "SIGTERM");
516 const deadline = Date.now() + 10_000;
517 while (alive(state.runnerPid) && Date.now() < deadline) {
518 await new Promise((resolve) => setTimeout(resolve, 200));
519 }
520 }
521 // Runner gone (or was already): make sure the children are too.
522 for (const pid of state.childPids ?? []) {
523 try {
524 process.kill(-pid, "SIGKILL");
525 } catch {
526 try {
527 process.kill(pid, "SIGKILL");
528 } catch {
529 // already gone
530 }
531 }
532 }
533 if (state.servePorts) {
534 const ts = await findTailscale();
535 if (ts) for (const port of state.servePorts) await sh(ts, ["serve", `--https=${port}`, "off"]);
536 }
537 rmSync(statePath(targetName), { force: true });
538 console.log(`${targetName}: down`);
539};
540
541const logs = (targetName: string) => {
542 const state = readState(targetName);

Callers 1

mainFunction · 0.70

Calls 6

readStateFunction · 0.85
aliveFunction · 0.85
findTailscaleFunction · 0.85
statePathFunction · 0.85
logMethod · 0.80
shFunction · 0.70

Tested by

no test coverage detected