Merge pull request +8407 from c9/fix/log-caught-exceptions

Adding stack trace and crash information to logs when a service crashes
pull/117/merge
Lennart Kats 2015-07-28 15:15:01 +02:00
commit 860f4c5685
1 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -23,15 +23,21 @@ function plugin(options, imports, register) {
connect.useStart(function(req, res, next) {
var d = domain.create();
d.on("error", function(err) {
raygun.customData = raygun.customData || {};
raygun.customData.serverCrashed = true;
raygun.customData.exceptionStack = err.stack;
raygun.customData.crashStack = new Error().stack;
sendRequestError(err, req);
// from http://nodejs.org/api/domain.html
try {
// make sure we close down within 10 seconds
console.error("Uncaught exception. Logging error and shutting down in 10 sec");
console.error("Exception:", err);
console.error("Exception stack:", err.stack);
console.error("Our current stack: ", new Error().stack);
var killtimer = setTimeout(function() {
console.error("Exiting after uncaught exception");
console.error(err.stack || err);
process.exit(1);
}, 10000);
// But don't keep the process open just for that!
@ -101,4 +107,4 @@ function plugin(options, imports, register) {
sendRequestError: sendRequestError,
sendRequestWarning: sendRequestWarning
}});
}
}