On page 202, here is the sample code to handle error on domain. However, I don’t quite understand the whole example. I looked at sample at http://nodejs.org/api/domain.html but this do not use express. Can you provide full sample for following sample?
// Domain error handler
d.on('error', function(err) {
// Stop accepting new connections
server.close();
// Perform last-minute cleanup
res.send(500);
// Let the master know the worker has disconnected
cluster.worker.disconnect();
// Terminate the process in 5 seconds
setTimeout(function() {
// Exit with a failure code
process.process.exit(1);
}, 5000);
});