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

Function stopSidecar

apps/desktop/src/main/sidecar.ts:470–496  ·  view source on GitHub ↗
(child: ChildProcess)

Source from the content-addressed store, hash-verified

468}
469
470export async function stopSidecar(child: ChildProcess): Promise<void> {
471 expectedExits.add(child);
472 const cleanupManifest = () => {
473 if (!child.pid) return;
474 const dataDir = sidecarManifestPathByPid.get(child.pid);
475 if (!dataDir) return;
476 removeManifestIfOwnedBy(dataDir, child.pid);
477 sidecarManifestPathByPid.delete(child.pid);
478 };
479 if (child.exitCode !== null || child.killed) {
480 cleanupManifest();
481 return;
482 }
483 return new Promise<void>((resolveStop) => {
484 const timeout = setTimeout(() => {
485 child.kill("SIGKILL");
486 cleanupManifest();
487 resolveStop();
488 }, 5000);
489 child.once("exit", () => {
490 clearTimeout(timeout);
491 cleanupManifest();
492 resolveStop();
493 });
494 child.kill("SIGTERM");
495 });
496}
497
498export type { DesktopServerSettings };

Callers 2

stopConnectionFunction · 0.90
exitAfterBootFunction · 0.85

Calls 2

cleanupManifestFunction · 0.85
killMethod · 0.80

Tested by 1

exitAfterBootFunction · 0.68