mirror of https://github.com/embarklabs/embark.git
Fix dynamic IPC
This commit is contained in:
parent
0f1f3a782a
commit
c92f6f8865
|
@ -79,18 +79,20 @@ class EmbarkController {
|
|||
context: self.context,
|
||||
useDashboard: options.useDashboard,
|
||||
webServerConfig: webServerConfig,
|
||||
webpackConfigName: options.webpackConfigName,
|
||||
ipcRole: 'server'
|
||||
webpackConfigName: options.webpackConfigName
|
||||
});
|
||||
engine.init();
|
||||
|
||||
if (!options.useDashboard) {
|
||||
engine.logger.info('========================'.bold.green);
|
||||
engine.logger.info((__('Welcome to Embark') + ' ' + this.version).yellow.bold);
|
||||
engine.logger.info('========================'.bold.green);
|
||||
}
|
||||
|
||||
async.parallel([
|
||||
async.waterfall([
|
||||
function initEngine(callback) {
|
||||
engine.init({}, () => {
|
||||
if (!options.useDashboard) {
|
||||
engine.logger.info('========================'.bold.green);
|
||||
engine.logger.info((__('Welcome to Embark') + ' ' + engine.version).yellow.bold);
|
||||
engine.logger.info('========================'.bold.green);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function startDashboard(callback) {
|
||||
if (!options.useDashboard) {
|
||||
return callback();
|
||||
|
@ -182,9 +184,12 @@ class EmbarkController {
|
|||
context: this.context,
|
||||
webpackConfigName: options.webpackConfigName
|
||||
});
|
||||
engine.init();
|
||||
|
||||
|
||||
async.waterfall([
|
||||
function initEngine(callback) {
|
||||
engine.init({}, callback);
|
||||
},
|
||||
function startServices(callback) {
|
||||
let pluginList = engine.plugins.listPlugins();
|
||||
if (pluginList.length > 0) {
|
||||
|
@ -250,8 +255,11 @@ class EmbarkController {
|
|||
context: this.context,
|
||||
webpackConfigName: options.webpackConfigName
|
||||
});
|
||||
engine.init();
|
||||
|
||||
async.waterfall([
|
||||
function initEngine(callback) {
|
||||
engine.init({}, callback);
|
||||
},
|
||||
function startServices(callback) {
|
||||
let pluginList = engine.plugins.listPlugins();
|
||||
if (pluginList.length > 0) {
|
||||
|
@ -350,9 +358,12 @@ class EmbarkController {
|
|||
logFile: options.logFile,
|
||||
context: this.context
|
||||
});
|
||||
engine.init();
|
||||
|
||||
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
engine.init({}, callback);
|
||||
},
|
||||
function (callback) {
|
||||
let pluginList = engine.plugins.listPlugins();
|
||||
if (pluginList.length > 0) {
|
||||
|
@ -436,12 +447,17 @@ class EmbarkController {
|
|||
context: this.context,
|
||||
webpackConfigName: options.webpackConfigName
|
||||
});
|
||||
engine.init();
|
||||
|
||||
let platform = engine.config.storageConfig.upload.provider;
|
||||
|
||||
let platform;
|
||||
|
||||
async.waterfall([
|
||||
|
||||
function initEngine(callback) {
|
||||
engine.init({}, () => {
|
||||
platform = engine.config.storageConfig.upload.provider;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function startServices(callback) {
|
||||
|
||||
engine.startService("processManager");
|
||||
|
|
|
@ -17,11 +17,11 @@ class Engine {
|
|||
this.context = options.context;
|
||||
this.useDashboard = options.useDashboard;
|
||||
this.webServerConfig = options.webServerConfig;
|
||||
this.ipcRole = options.ipcRole;
|
||||
this.webpackConfigName = options.webpackConfigName;
|
||||
}
|
||||
|
||||
init(_options) {
|
||||
init(_options, callback) {
|
||||
callback = callback || function() {};
|
||||
const Events = require('./events.js');
|
||||
const Logger = require('./logger.js');
|
||||
const Config = require('./config.js');
|
||||
|
@ -38,22 +38,13 @@ class Engine {
|
|||
utils.interceptLogs(console, this.logger);
|
||||
}
|
||||
|
||||
if (this.ipcRole) {
|
||||
this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole});
|
||||
|
||||
if(this.ipc.isServer()) {
|
||||
this.ipc.serve();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.ipc = new IPC({logger: this.logger, ipcRole: 'client'});
|
||||
this.ipc.connect((err) => {
|
||||
if(err) {
|
||||
this.ipc = new IPC({logger: this.logger, ipcRole: 'server'});
|
||||
this.ipc.serve();
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class IPC {
|
|||
constructor(options) {
|
||||
this.logger = options.logger;
|
||||
this.socketPath = options.socketPath || fs.dappPath(".embark/embark.ipc");
|
||||
this.ipcRole = options.ipcRole || "server";
|
||||
this.ipcRole = options.ipcRole;
|
||||
ipc.config.silent = true;
|
||||
this.connected = false;
|
||||
}
|
||||
|
|
|
@ -116,48 +116,52 @@ class Test {
|
|||
}
|
||||
|
||||
init(callback) {
|
||||
let self = this;
|
||||
this.engine = new Engine({
|
||||
env: this.options.env || 'test',
|
||||
// TODO: config will need to detect if this is a obj
|
||||
embarkConfig: this.options.embarkConfig || 'embark.json',
|
||||
interceptLogs: false,
|
||||
ipcRole: 'client'
|
||||
interceptLogs: false
|
||||
});
|
||||
async.waterfall([
|
||||
function initEngine(cb) {
|
||||
self.engine.init({
|
||||
logger: new TestLogger({logLevel: self.options.loglevel})
|
||||
}, cb);
|
||||
},
|
||||
function startServices(cb) {
|
||||
self.versions_default = self.engine.config.contractsConfig.versions;
|
||||
// Reset contract config to nothing to make sure we deploy only what we want
|
||||
self.engine.config.contractsConfig = {
|
||||
contracts: {},
|
||||
versions: self.versions_default
|
||||
};
|
||||
|
||||
this.engine.init({
|
||||
logger: new TestLogger({logLevel: this.options.loglevel})
|
||||
});
|
||||
self.engine.startService("libraryManager");
|
||||
self.engine.startService("codeRunner");
|
||||
self.initDeployServices();
|
||||
self.engine.startService("codeGenerator");
|
||||
self.engine.startService("codeCoverage");
|
||||
|
||||
this.versions_default = this.engine.config.contractsConfig.versions;
|
||||
// Reset contract config to nothing to make sure we deploy only what we want
|
||||
this.engine.config.contractsConfig = {
|
||||
contracts: {},
|
||||
versions: this.versions_default
|
||||
};
|
||||
|
||||
this.engine.startService("libraryManager");
|
||||
this.engine.startService("codeRunner");
|
||||
this.initDeployServices();
|
||||
this.engine.startService("codeGenerator");
|
||||
this.engine.startService("codeCoverage");
|
||||
|
||||
if (this.options.node === 'embark') {
|
||||
return this.engine.ipc.connect((err) => {
|
||||
if (err) {
|
||||
this.engine.logger.error(err.message || err);
|
||||
this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?");
|
||||
process.exit(1);
|
||||
if (self.options.node === 'embark') {
|
||||
return self.engine.ipc.connect((err) => {
|
||||
if (err) {
|
||||
this.engine.logger.error(err.message || err);
|
||||
this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?");
|
||||
process.exit(1);
|
||||
}
|
||||
self.engine.ipc.request('blockchain:node', {}, (err, node) => {
|
||||
if (err) {
|
||||
return self.engine.logger.error(err.message || err);
|
||||
}
|
||||
self.options.node = node;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
this.engine.ipc.request('blockchain:node', {}, (err, node) => {
|
||||
if (err) {
|
||||
return this.engine.logger.error(err.message || err);
|
||||
}
|
||||
this.options.node = node;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
callback();
|
||||
cb();
|
||||
}
|
||||
], callback);
|
||||
}
|
||||
|
||||
onReady(callback) {
|
||||
|
|
Loading…
Reference in New Issue