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

Function stopSidecar

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

Source from the content-addressed store, hash-verified

445}
446
447export async function stopSidecar(child: ChildProcess): Promise<void> {
448 expectedExits.add(child);
449 const cleanupManifest = () => {
450 if (!child.pid) return;
451 const dataDir = sidecarManifestPathByPid.get(child.pid);
452 if (!dataDir) return;
453 removeManifestIfOwnedBy(dataDir, child.pid);
454 sidecarManifestPathByPid.delete(child.pid);
455 };
456 if (child.exitCode !== null || child.killed) {
457 cleanupManifest();
458 return;
459 }
460 return new Promise<void>((resolveStop) => {
461 const timeout = setTimeout(() => {
462 child.kill("SIGKILL");
463 cleanupManifest();
464 resolveStop();
465 }, 5000);
466 child.once("exit", () => {
467 clearTimeout(timeout);
468 cleanupManifest();
469 resolveStop();
470 });
471 child.kill("SIGTERM");
472 });
473}
474
475export type { DesktopServerSettings };

Callers 1

stopConnectionFunction · 0.90

Calls 1

cleanupManifestFunction · 0.85

Tested by

no test coverage detected