Closed ORESoftware closed 3 weeks ago
Here: https://stackoverflow.com/questions/78144749/using-node-js-how-to-stop-new-requests-before-closing-existing-ones
The question is:
version 20+
const server = app.listen(3900, '0.0.0.0', () => { console.log('listening...'); }); process.once('SIGINT', () => { console.log('got SIGINT.') setTimeout(() => { console.log('ending process due to SIGINT + subsequent Timeout.') process.exit(0); }, 3000); server.closeIdleConnections(); server.closeAllConnections(); server.close(err => { if (err) { console.error(err); } console.log('closed server, and now shutting down due to SIGINT.') process.exit(0); }); });
darwin/linux
http
I updated an answer to the OP: https://stackoverflow.com/questions/78144749/how-to-stop-new-requests-before-closing-existing-ones/78163844#78163844
Details
Here: https://stackoverflow.com/questions/78144749/using-node-js-how-to-stop-new-requests-before-closing-existing-ones
The question is:
Node.js version
version 20+
Example code
Operating system
darwin/linux
Scope
http
Module and version
http