| 2492 | // The http server keeps the event loop alive on its own; these just make |
| 2493 | // Ctrl-C hang up live sockets instead of waiting on browser keep-alives. |
| 2494 | const shutdown = (): void => { |
| 2495 | // Release the SQLite handle before the socket: the process should never |
| 2496 | // exit with a live connection to the user's index. |
| 2497 | api.close(); |
| 2498 | void handle.close().then(() => process.exit(0)); |
| 2499 | }; |
| 2500 | process.once('SIGINT', shutdown); |
| 2501 | process.once('SIGTERM', shutdown); |
| 2502 | // Killing the command the user started (its pid, not Ctrl+C's process |