From 1bca31184e76f3134b78eae27b4fd5129251aaed Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 23 May 2018 10:51:42 -0400 Subject: [PATCH] always show process messages if error and catch geth errors --- lib/cmds/blockchain/blockchain.js | 12 ++++++++++-- lib/process/processLauncher.js | 6 +++++- lib/processes/blockchainProcessLauncher.js | 3 +-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 38e364fbb..254f5ce87 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -112,12 +112,20 @@ Blockchain.prototype.run = function() { }); if (self.onReadyCallback) { // Geth logs appear in stderr somehow + let lastMessage; child.stderr.on('data', (data) => { if (!self.readyCalled && data.indexOf('Mapped network port') > -1) { self.readyCalled = true; - return self.onReadyCallback(); + self.onReadyCallback(); + } + lastMessage = data; + console.log('Geth: ' + data); + }); + child.on('exit', (code) => { + if (code) { + console.error('Geth exited with error code ' + 1); + console.error(lastMessage); } - console.log('Geth:' + data); }); } }); diff --git a/lib/process/processLauncher.js b/lib/process/processLauncher.js index be7f4fd42..15a9f95a6 100644 --- a/lib/process/processLauncher.js +++ b/lib/process/processLauncher.js @@ -36,11 +36,15 @@ class ProcessLauncher { } self._checkSubscriptions(msg); }); + + this.process.on('exit', (code) => { + self.logger.info('Process exited with code ' + code); + }); } // Translates logs from the child process to the logger _handleLog(msg) { - if (this.silent) { + if (this.silent && msg.type !== 'error') { return; } if (this.logger[msg.type]) { diff --git a/lib/processes/blockchainProcessLauncher.js b/lib/processes/blockchainProcessLauncher.js index 359a5a22a..9b089d764 100644 --- a/lib/processes/blockchainProcessLauncher.js +++ b/lib/processes/blockchainProcessLauncher.js @@ -20,8 +20,7 @@ class BlockchainProcessLauncher { logger: this.logger, events: this.events, normalizeInput: this.normalizeInput, - //silent: true - silent: false + silent: true }); this.blockchainProcess.send({ action: constants.blockchain.init, options: {