Merge pull request #107 from pnagurny/bug/daemon-error

Fix uncaught exception handling
This commit is contained in:
Braydon Fuller 2015-08-06 17:22:15 -04:00
commit 4dad90138b
1 changed files with 9 additions and 4 deletions

View File

@ -144,10 +144,10 @@ Daemon.prototype.start = function(options, callback) {
return;
}
errorCaught = err;
self.error('Uncaught error: shutting down safely before throwing...');
log.error('Uncaught error: shutting down safely before throwing...');
if (!self._shutdown) {
if (err && err.stack) {
console.error(err.stack);
log.error(err.stack);
}
self._exit(1);
return;
@ -219,11 +219,16 @@ Daemon.prototype.start = function(options, callback) {
process.kill(process.pid, exitCaught.name);
});
return;
} else if (errorCaught && errorCaught.stack) {
console.error(errorCaught.stack);
}
return self._exit(exitCaught);
}
if (errorCaught !== none) {
if (errorCaught && errorCaught.stack) {
log.error(errorCaught.stack);
}
return self._exit(0);
}
}
}, 1000);
};