From bf97074d78d6efcbe4c1bc8a12ece43effaf43f9 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 21 Nov 2017 16:25:19 +0300 Subject: [PATCH] catch coind proc exit --- routes/shepherd/daemonControl.js | 11 ++++++++++- routes/shepherd/dashboardUpdate.js | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/routes/shepherd/daemonControl.js b/routes/shepherd/daemonControl.js index 5228669..262bd24 100644 --- a/routes/shepherd/daemonControl.js +++ b/routes/shepherd/daemonControl.js @@ -237,7 +237,16 @@ module.exports = (shepherd) => { }).pipe(logStream); _daemonChildProc.on('exit', (exitCode) => { - }).pipe(logStream); + const _errMsg = exitCode === 0 ? `${_daemonName} exited with code ${exitCode}` : `${_daemonName} exited with code ${exitCode}, crashed?`; + + fs.appendFile(_daemonLogName, _errMsg, (err) => { + if (err) { + shepherd.writeLog(_errMsg); + shepherd.log(_errMsg); + } + shepherd.log(_errMsg); + }); + }); } } } else { diff --git a/routes/shepherd/dashboardUpdate.js b/routes/shepherd/dashboardUpdate.js index 9ca48ff..2b34590 100644 --- a/routes/shepherd/dashboardUpdate.js +++ b/routes/shepherd/dashboardUpdate.js @@ -69,7 +69,8 @@ module.exports = (shepherd) => { })) .then(result => { if (result[0] && - result[0].length) { + result[0].length && + result[0][0].address) { const calcBalance = (result, json) => { if (json && json.length &&