launch blockchain in separate process
works but still cant getAccounts
This commit is contained in:
parent
aea270af02
commit
3fcc36a7a1
|
@ -111,6 +111,7 @@ class Cmd {
|
|||
program
|
||||
.command('run [environment]')
|
||||
.option('-p, --port [port]', __('port to run the dev webserver (default: %s)', '8000'))
|
||||
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
|
||||
.option('-b, --host [host]', __('host to run the dev webserver (default: %s)', 'localhost'))
|
||||
.option('--noserver', __('disable the development webserver'))
|
||||
.option('--nodashboard', __('simple mode, disables the dashboard'))
|
||||
|
@ -125,6 +126,8 @@ class Cmd {
|
|||
env: env || 'development',
|
||||
serverPort: options.port,
|
||||
serverHost: options.host,
|
||||
client: options.client || 'geth',
|
||||
locale: options.locale,
|
||||
runWebserver: !options.noserver,
|
||||
useDashboard: !options.nodashboard,
|
||||
logFile: options.logfile,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
const ProcessWrapper = require('../../process/processWrapper');
|
||||
const BlockchainClient = require('./blockchain');
|
||||
const i18n = require('../../i18n/i18n.js');
|
||||
|
||||
class BlockchainProcess extends ProcessWrapper {
|
||||
constructor(options) {
|
||||
super();
|
||||
this.blockchainConfig = options.blockchainConfig;
|
||||
this.client = options.client;
|
||||
this.env = options.env;
|
||||
this.isDev = options.isDev;
|
||||
|
||||
i18n.setOrDetectLocale(options.locale);
|
||||
|
||||
this.blockchain = BlockchainClient(this.blockchainConfig, this.client, this.env, this.isDev);
|
||||
this.blockchain.run();
|
||||
}
|
||||
}
|
||||
|
||||
process.on('message', (msg) => {
|
||||
if (msg.action === 'init') {
|
||||
const blockchainProcess = new BlockchainProcess(msg.options);
|
||||
return process.send({result: 'initiated'});
|
||||
}
|
||||
});
|
|
@ -14,12 +14,16 @@ const Watch = require('../pipeline/watch.js');
|
|||
const LibraryManager = require('../versions/library_manager.js');
|
||||
const CodeRunner = require('../coderunner/codeRunner.js');
|
||||
const request = require('request');
|
||||
//const Provider = require('../contracts/provider');
|
||||
|
||||
const ProcessLauncher = require('../process/processLauncher');
|
||||
const utils = require('../utils/utils');
|
||||
|
||||
class Engine {
|
||||
constructor(options) {
|
||||
this.env = options.env;
|
||||
this.isDev = options.isDev;
|
||||
this.client = options.client;
|
||||
this.locale = options.locale;
|
||||
this.embarkConfig = options.embarkConfig;
|
||||
this.interceptLogs = options.interceptLogs;
|
||||
this.version = options.version;
|
||||
|
@ -319,6 +323,25 @@ class Engine {
|
|||
});
|
||||
}
|
||||
|
||||
startBlockchainNode() {
|
||||
this.blockchainProcess = new ProcessLauncher({
|
||||
modulePath: utils.joinPath(__dirname, '../cmds/blockchain/blockchainProcess.js'),
|
||||
logger: this.logger,
|
||||
events: this.events,
|
||||
normalizeInput: this.normalizeInput,
|
||||
silent: true
|
||||
});
|
||||
this.blockchainProcess.send({
|
||||
action: 'init', options: {
|
||||
blockchainConfig: this.config.blockchainConfig,
|
||||
client: this.client,
|
||||
env: this.env,
|
||||
isDev: this.isDev,
|
||||
locale: this.locale
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
libraryManagerService(_options) {
|
||||
this.libraryManager = new LibraryManager({
|
||||
plugins: this.plugins,
|
||||
|
|
|
@ -86,6 +86,8 @@ class Embark {
|
|||
|
||||
let engine = new Engine({
|
||||
env: options.env,
|
||||
client: options.client,
|
||||
locale: options.locale,
|
||||
isDev: this.isDev(options.env),
|
||||
version: this.version,
|
||||
embarkConfig: options.embarkConfig || 'embark.json',
|
||||
|
|
|
@ -18,6 +18,7 @@ class ProcessLauncher {
|
|||
this.logger = options.logger;
|
||||
this.normalizeInput = options.normalizeInput;
|
||||
this.events = options.events;
|
||||
this.silent = options.silent;
|
||||
|
||||
this.subscriptions = {};
|
||||
this._subscribeToMessages();
|
||||
|
@ -31,14 +32,18 @@ class ProcessLauncher {
|
|||
return self._handleLog(msg);
|
||||
}
|
||||
if (msg.event) {
|
||||
return this._handleEvent(msg);
|
||||
return self._handleEvent(msg);
|
||||
}
|
||||
this._checkSubscriptions(msg);
|
||||
self._checkSubscriptions(msg);
|
||||
});
|
||||
}
|
||||
|
||||
// Translates logs from the child process to the logger
|
||||
_handleLog(msg) {
|
||||
if (this.silent) {
|
||||
return;
|
||||
}
|
||||
console.log('Not silent????', this.silent);
|
||||
if (this.logger[msg.type]) {
|
||||
return this.logger[msg.type](this.normalizeInput(msg.message));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue