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
|
program
|
||||||
.command('run [environment]')
|
.command('run [environment]')
|
||||||
.option('-p, --port [port]', __('port to run the dev webserver (default: %s)', '8000'))
|
.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('-b, --host [host]', __('host to run the dev webserver (default: %s)', 'localhost'))
|
||||||
.option('--noserver', __('disable the development webserver'))
|
.option('--noserver', __('disable the development webserver'))
|
||||||
.option('--nodashboard', __('simple mode, disables the dashboard'))
|
.option('--nodashboard', __('simple mode, disables the dashboard'))
|
||||||
|
@ -125,6 +126,8 @@ class Cmd {
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
serverPort: options.port,
|
serverPort: options.port,
|
||||||
serverHost: options.host,
|
serverHost: options.host,
|
||||||
|
client: options.client || 'geth',
|
||||||
|
locale: options.locale,
|
||||||
runWebserver: !options.noserver,
|
runWebserver: !options.noserver,
|
||||||
useDashboard: !options.nodashboard,
|
useDashboard: !options.nodashboard,
|
||||||
logFile: options.logfile,
|
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 LibraryManager = require('../versions/library_manager.js');
|
||||||
const CodeRunner = require('../coderunner/codeRunner.js');
|
const CodeRunner = require('../coderunner/codeRunner.js');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
//const Provider = require('../contracts/provider');
|
|
||||||
|
const ProcessLauncher = require('../process/processLauncher');
|
||||||
|
const utils = require('../utils/utils');
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.isDev = options.isDev;
|
this.isDev = options.isDev;
|
||||||
|
this.client = options.client;
|
||||||
|
this.locale = options.locale;
|
||||||
this.embarkConfig = options.embarkConfig;
|
this.embarkConfig = options.embarkConfig;
|
||||||
this.interceptLogs = options.interceptLogs;
|
this.interceptLogs = options.interceptLogs;
|
||||||
this.version = options.version;
|
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) {
|
libraryManagerService(_options) {
|
||||||
this.libraryManager = new LibraryManager({
|
this.libraryManager = new LibraryManager({
|
||||||
plugins: this.plugins,
|
plugins: this.plugins,
|
||||||
|
|
|
@ -86,6 +86,8 @@ class Embark {
|
||||||
|
|
||||||
let engine = new Engine({
|
let engine = new Engine({
|
||||||
env: options.env,
|
env: options.env,
|
||||||
|
client: options.client,
|
||||||
|
locale: options.locale,
|
||||||
isDev: this.isDev(options.env),
|
isDev: this.isDev(options.env),
|
||||||
version: this.version,
|
version: this.version,
|
||||||
embarkConfig: options.embarkConfig || 'embark.json',
|
embarkConfig: options.embarkConfig || 'embark.json',
|
||||||
|
|
|
@ -18,6 +18,7 @@ class ProcessLauncher {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.normalizeInput = options.normalizeInput;
|
this.normalizeInput = options.normalizeInput;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
|
this.silent = options.silent;
|
||||||
|
|
||||||
this.subscriptions = {};
|
this.subscriptions = {};
|
||||||
this._subscribeToMessages();
|
this._subscribeToMessages();
|
||||||
|
@ -31,14 +32,18 @@ class ProcessLauncher {
|
||||||
return self._handleLog(msg);
|
return self._handleLog(msg);
|
||||||
}
|
}
|
||||||
if (msg.event) {
|
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
|
// Translates logs from the child process to the logger
|
||||||
_handleLog(msg) {
|
_handleLog(msg) {
|
||||||
|
if (this.silent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('Not silent????', this.silent);
|
||||||
if (this.logger[msg.type]) {
|
if (this.logger[msg.type]) {
|
||||||
return this.logger[msg.type](this.normalizeInput(msg.message));
|
return this.logger[msg.type](this.normalizeInput(msg.message));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue