()
| 39 | |
| 40 | let shuttingDown = false |
| 41 | function shutdown() { |
| 42 | if (shuttingDown) return |
| 43 | shuttingDown = true |
| 44 | |
| 45 | // Allow Node to exit cleanly so --cpu-prof/--heap-prof outputs are flushed. |
| 46 | server.close(() => { |
| 47 | process.exit(0) |
| 48 | }) |
| 49 | |
| 50 | // Fallback in case active keep-alive connections prevent close callback. |
| 51 | setTimeout(() => { |
| 52 | process.exit(1) |
| 53 | }, 5000).unref() |
| 54 | } |
| 55 | |
| 56 | process.on('SIGTERM', shutdown) |
| 57 | process.on('SIGINT', shutdown) |
no test coverage detected