From c2b062f5352e558d7384130d9f1cb702f0cf5b37 Mon Sep 17 00:00:00 2001 From: Patrick Nagurny Date: Thu, 6 Aug 2015 17:14:14 -0400 Subject: [PATCH] fix uncaught exception handling --- lib/daemon.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/daemon.js b/lib/daemon.js index 101cd605..e10a08cd 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -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); };