MCPcopy Create free account
hub / github.com/cloudflare/computer / shutdown

Function shutdown

packages/computerd/src/cli/computerd.ts:569–597  ·  view source on GitHub ↗
(signal: NodeJS.Signals)

Source from the content-addressed store, hash-verified

567
568 let shuttingDown = false;
569 const shutdown = async (signal: NodeJS.Signals): Promise<void> => {
570 if (shuttingDown) return;
571 shuttingDown = true;
572
573 try {
574 await http.close();
575 } catch (error) {
576 console.error(error);
577 }
578 try {
579 runner.disposeAll();
580 } catch (error) {
581 console.error(error);
582 }
583
584 if (fuse !== undefined) {
585 await unmount(fuse);
586 }
587 if (upstreamClient !== undefined) {
588 try {
589 stopSync();
590 await upstreamClient.close();
591 } catch (error) {
592 console.error(error);
593 }
594 }
595 teardownLogging();
596 process.exit(signal === "SIGINT" ? 130 : 143);
597 };
598
599 process.once("SIGINT", (signal) => void shutdown(signal));
600 process.once("SIGTERM", (signal) => void shutdown(signal));

Callers 1

mainFunction · 0.85

Calls 5

stopSyncFunction · 0.85
disposeAllMethod · 0.80
unmountFunction · 0.70
closeMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected