From 59e82d5fc61329fc6eb047911af47c4a132c5fa8 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Thu, 30 Aug 2018 15:45:01 +0100 Subject: [PATCH] Console can be a client or server ipc --- cmd/cmd_controller.js | 4 ++-- lib/core/engine.js | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index b9819b78e..689ddd99f 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -80,7 +80,8 @@ class EmbarkController { context: self.context, useDashboard: options.useDashboard, webServerConfig: webServerConfig, - webpackConfigName: options.webpackConfigName + webpackConfigName: options.webpackConfigName, + ipcRole: 'server' }); engine.init(); @@ -256,7 +257,6 @@ class EmbarkController { logFile: options.logFile, logLevel: options.logLevel, context: this.context, - ipcRole: 'client', webpackConfigName: options.webpackConfigName }); engine.init(); diff --git a/lib/core/engine.js b/lib/core/engine.js index 3c54aa368..b6095a714 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -38,10 +38,23 @@ class Engine { utils.interceptLogs(console, this.logger); } - this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole}); - if (this.ipc.isServer()) { - this.ipc.serve(); + 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(); + } + }); } registerModule(moduleName, options) {