MCPcopy Create free account
hub / github.com/VisActor/vchart-mcp-server / setupCleanupHandlers

Function setupCleanupHandlers

src/utils/httpServer.ts:70–90  ·  view source on GitHub ↗

* Sets up signal handlers for graceful shutdown

(
  httpServer: http.Server,
  customCleanup?: () => void
)

Source from the content-addressed store, hash-verified

68 * Sets up signal handlers for graceful shutdown
69 */
70function setupCleanupHandlers(
71 httpServer: http.Server,
72 customCleanup?: () => void
73): void {
74 const cleanup = () => {
75 console.log('\nClosing server...');
76
77 // Execute custom cleanup if provided
78 if (customCleanup) {
79 customCleanup();
80 }
81
82 httpServer.close(() => {
83 console.log('Server closed');
84 process.exit(0);
85 });
86 };
87
88 process.on('SIGINT', cleanup);
89 process.on('SIGTERM', cleanup);
90}
91
92/**
93 * Logs server startup information with formatted URLs

Callers 1

createBaseHttpServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected