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