15
I have an nodejs server running express to server out http calls. Is there a recommended approach to shutting down the server gracefully if something bad happens? Should I leave the server running somehow?
I.E. on an uncaught exception the server just stops, I think this will kill over connected clients and not hand them back a response.
Should I:
- Wait for all http connections to complete before I allow the server to die (and then restart it).
- Or should I try and stop the server from ever dieing?
is this proper?
process.on('exit', function () {
console.log('About to exit, waiting for remaining connections to complete');
app.close();
});
In this case an error might have been thrown leaving the server in an undefined state and the server will continue to finish up remaining connections.
Is there any good way to handle errors keep running or should I let the server die and restart?