show message when process doesnt end with code 0
This commit is contained in:
parent
1bca31184e
commit
688a39b8bc
|
@ -1,6 +1,6 @@
|
|||
const child_process = require('child_process');
|
||||
const constants = require('../constants');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
class ProcessLauncher {
|
||||
|
||||
|
@ -14,11 +14,13 @@ class ProcessLauncher {
|
|||
* @return {ProcessLauncher} The ProcessLauncher instance
|
||||
*/
|
||||
constructor(options) {
|
||||
this.name = path.basename(options.modulePath);
|
||||
this.process = child_process.fork(options.modulePath);
|
||||
this.logger = options.logger;
|
||||
this.normalizeInput = options.normalizeInput;
|
||||
this.events = options.events;
|
||||
this.silent = options.silent;
|
||||
this.exitCallback = options.exitCallback;
|
||||
|
||||
this.subscriptions = {};
|
||||
this._subscribeToMessages();
|
||||
|
@ -38,7 +40,12 @@ class ProcessLauncher {
|
|||
});
|
||||
|
||||
this.process.on('exit', (code) => {
|
||||
self.logger.info('Process exited with code ' + code);
|
||||
if (self.exitCallback) {
|
||||
return self.exitCallback(code);
|
||||
}
|
||||
if (code) {
|
||||
this.logger.info(`Child Process ${this.name} exited with code ${code}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@ class BlockchainProcessLauncher {
|
|||
this.locale = options.locale;
|
||||
}
|
||||
|
||||
processEnded(code) {
|
||||
this.logger.error('Blockchain process ended before the end of this process. Code: ' + code);
|
||||
}
|
||||
|
||||
startBlockchainNode() {
|
||||
this.logger.info('Starting Blockchain node in another process'.cyan);
|
||||
|
||||
|
@ -20,7 +24,8 @@ class BlockchainProcessLauncher {
|
|||
logger: this.logger,
|
||||
events: this.events,
|
||||
normalizeInput: this.normalizeInput,
|
||||
silent: true
|
||||
silent: true,
|
||||
exitCallback: this.processEnded.bind(this)
|
||||
});
|
||||
this.blockchainProcess.send({
|
||||
action: constants.blockchain.init, options: {
|
||||
|
|
Loading…
Reference in New Issue