()
| 4158 | }); |
| 4159 | let shuttingDown = false; |
| 4160 | const shutdown = async () => { |
| 4161 | if (shuttingDown) return; |
| 4162 | shuttingDown = true; |
| 4163 | // Stop accepting new connections before tearing down sessions. |
| 4164 | server.stop(true); |
| 4165 | await sessionManager.destroyAll(); |
| 4166 | await removeServerLock(); |
| 4167 | process.exit(0); |
| 4168 | }; |
| 4169 | process.once('SIGINT', () => void shutdown()); |
| 4170 | process.once('SIGTERM', () => void shutdown()); |
| 4171 | }); |