* Sets up signal handlers for graceful shutdown
( httpServer: http.Server, customCleanup?: () => void )
| 68 | * Sets up signal handlers for graceful shutdown |
| 69 | */ |
| 70 | function 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 |
no outgoing calls
no test coverage detected