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

Function stopSidecar

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

Source from the content-addressed store, hash-verified

480}
481
482export async function stopSidecar(child: ChildProcess): Promise<void> {
483 expectedExits.add(child);
484 const cleanupManifest = () => {
485 if (!child.pid) return;
486 const dataDir = sidecarManifestPathByPid.get(child.pid);
487 if (!dataDir) return;
488 removeManifestIfOwnedBy(dataDir, child.pid);
489 sidecarManifestPathByPid.delete(child.pid);
490 };
491 if (child.exitCode !== null || child.killed) {
492 cleanupManifest();
493 return;
494 }
495 return new Promise<void>((resolveStop) => {
496 const timeout = setTimeout(() => {
497 child.kill("SIGKILL");
498 cleanupManifest();
499 resolveStop();
500 }, 5000);
501 child.once("exit", () => {
502 clearTimeout(timeout);
503 cleanupManifest();
504 resolveStop();
505 });
506 child.kill("SIGTERM");
507 });
508}
509
510export type { DesktopServerSettings };

Callers 2

stopConnectionFunction · 0.90
exitAfterBootFunction · 0.85

Calls 2

cleanupManifestFunction · 0.85
killMethod · 0.80

Tested by 1

exitAfterBootFunction · 0.68