always show process messages if error and catch geth errors

This commit is contained in:
Jonathan Rainville 2018-05-23 10:51:42 -04:00
parent 4815555a89
commit 1bca31184e
3 changed files with 16 additions and 5 deletions

View File

@ -112,13 +112,21 @@ Blockchain.prototype.run = function() {
}); });
if (self.onReadyCallback) { if (self.onReadyCallback) {
// Geth logs appear in stderr somehow // Geth logs appear in stderr somehow
let lastMessage;
child.stderr.on('data', (data) => { child.stderr.on('data', (data) => {
if (!self.readyCalled && data.indexOf('Mapped network port') > -1) { if (!self.readyCalled && data.indexOf('Mapped network port') > -1) {
self.readyCalled = true; self.readyCalled = true;
return self.onReadyCallback(); self.onReadyCallback();
} }
lastMessage = data;
console.log('Geth: ' + data); console.log('Geth: ' + data);
}); });
child.on('exit', (code) => {
if (code) {
console.error('Geth exited with error code ' + 1);
console.error(lastMessage);
}
});
} }
}); });
}; };

View File

@ -36,11 +36,15 @@ class ProcessLauncher {
} }
self._checkSubscriptions(msg); 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 // Translates logs from the child process to the logger
_handleLog(msg) { _handleLog(msg) {
if (this.silent) { if (this.silent && msg.type !== 'error') {
return; return;
} }
if (this.logger[msg.type]) { if (this.logger[msg.type]) {

View File

@ -20,8 +20,7 @@ class BlockchainProcessLauncher {
logger: this.logger, logger: this.logger,
events: this.events, events: this.events,
normalizeInput: this.normalizeInput, normalizeInput: this.normalizeInput,
//silent: true silent: true
silent: false
}); });
this.blockchainProcess.send({ this.blockchainProcess.send({
action: constants.blockchain.init, options: { action: constants.blockchain.init, options: {