Skip to content

Instantly share code, notes, and snippets.

@craigp
Last active August 29, 2015 14:09
Show Gist options
  • Save craigp/02f418b05a672dae5875 to your computer and use it in GitHub Desktop.
Save craigp/02f418b05a672dae5875 to your computer and use it in GitHub Desktop.
function apocalypse(exitOnError) {
process.on('uncaughtException', function(err) {
process.removeListener('uncaughtException', arguments.callee);
logger.fatal(err);
if (exitOnError) {
var s = logger.streams[0];
s.stream.on('error', function(streamErr, stream) {
console.log('Logging stream error:', streamErr);
});
s.stream.on('close', function(streamErr, stream) {
throw err;
});
setTimeout(function() {
s.stream.end();
}, 100);
} else {
apocalypse(exitOnError);
}
});
}
apocalypse(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment