diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 28288801..18a28c47 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -79,7 +79,8 @@ class EmbarkController { context: self.context, useDashboard: options.useDashboard, webServerConfig: webServerConfig, - webpackConfigName: options.webpackConfigName + webpackConfigName: options.webpackConfigName, + ipcRole: 'server' }); async.waterfall([ @@ -269,28 +270,24 @@ class EmbarkController { engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", ")); } - engine.ipc.connect((err) => { - if (err) { - engine.startService("processManager"); - engine.startService("serviceMonitor"); - engine.startService("libraryManager"); - engine.startService("codeRunner"); - engine.startService("web3"); - engine.startService("pipeline"); - engine.startService("deployment"); - engine.startService("storage"); - engine.startService("codeGenerator"); - engine.startService("webServer"); - engine.startService("namingSystem"); - engine.startService("console"); - engine.startService("pluginCommand"); - return callback(); - } - + if (engine.ipc.connected) { engine.startService("codeRunner"); engine.startService("console"); - callback(); - }); + return callback(); + } + engine.startService("processManager"); + engine.startService("serviceMonitor"); + engine.startService("libraryManager"); + engine.startService("codeRunner"); + engine.startService("web3"); + engine.startService("pipeline"); + engine.startService("deployment"); + engine.startService("storage"); + engine.startService("codeGenerator"); + engine.startService("namingSystem"); + engine.startService("console"); + engine.startService("pluginCommand"); + callback(); }, function web3IPC(callback) { // Do specific work in case we are connected to a socket: diff --git a/lib/core/engine.js b/lib/core/engine.js index 23af30e4..249b0afc 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -18,6 +18,7 @@ class Engine { this.useDashboard = options.useDashboard; this.webServerConfig = options.webServerConfig; this.webpackConfigName = options.webpackConfigName; + this.ipcRole = options.ipcRole || 'client'; } init(_options, callback) { @@ -38,14 +39,16 @@ class Engine { utils.interceptLogs(console, this.logger); } - 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(); - }); + this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole}); + if (this.ipc.isClient()) { + return this.ipc.connect((_err) => { + callback(); + }); + } else if (this.ipc.isServer()) { + this.ipc.serve(); + return callback(); + } + callback(); } registerModule(moduleName, options) {