Last active
August 29, 2015 14:09
-
-
Save craigp/02f418b05a672dae5875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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