propagate `embark run` cli webserver flags to config and service

This commit is contained in:
Michael Bradley, Jr 2018-07-15 23:49:24 -05:00
parent 07f600f756
commit dfaaa58ce0
3 changed files with 19 additions and 6 deletions

View File

@ -12,7 +12,7 @@ var Config = function(options) {
this.blockchainConfig = {}; this.blockchainConfig = {};
this.contractsConfig = {}; this.contractsConfig = {};
this.pipelineConfig = {}; this.pipelineConfig = {};
this.webServerConfig = {}; this.webServerConfig = options.webServerConfig;
this.chainTracker = {}; this.chainTracker = {};
this.assetFiles = {}; this.assetFiles = {};
this.contractsFiles = []; this.contractsFiles = [];
@ -314,7 +314,14 @@ Config.prototype.loadWebServerConfigFile = function() {
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver'); let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');
this.webServerConfig = this._mergeConfig(configFilePath, configObject, false); let webServerConfig = this._mergeConfig(configFilePath, configObject, false);
if (this.webServerConfig) {
// cli falgs to `embark run` should override configFile and defaults (configObject)
this.webServerConfig = utils.recursiveMerge(webServerConfig, this.webServerConfig);
} else {
this.webServerConfig = webServerConfig;
}
}; };
Config.prototype.loadEmbarkConfigFile = function() { Config.prototype.loadEmbarkConfigFile = function() {

View File

@ -16,6 +16,7 @@ class Engine {
this.events = options.events; this.events = options.events;
this.context = options.context; this.context = options.context;
this.useDashboard = options.useDashboard; this.useDashboard = options.useDashboard;
this.webServerConfig = options.webServerConfig;
} }
init(_options) { init(_options) {
@ -26,7 +27,7 @@ class Engine {
let options = _options || {}; let options = _options || {};
this.events = options.events || this.events || new Events(); this.events = options.events || this.events || new Events();
this.logger = options.logger || new Logger({logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile}); this.logger = options.logger || new Logger({logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile});
this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context}); this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig});
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs}); this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
this.plugins = this.config.plugins; this.plugins = this.config.plugins;
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default); this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
@ -248,8 +249,8 @@ class Engine {
this.watch.start(); this.watch.start();
} }
webServerService() { webServerService(_options) {
this.registerModule('webserver'); this.registerModule('webserver', _options);
} }
storageService(_options) { storageService(_options) {

View File

@ -75,7 +75,12 @@ class Embark {
logFile: options.logFile, logFile: options.logFile,
logLevel: options.logLevel, logLevel: options.logLevel,
context: self.context, context: self.context,
useDashboard: options.useDashboard useDashboard: options.useDashboard,
webServerConfig: {
enabled: options.runWebserver,
host: options.serverHost,
port: options.serverPort
}
}); });
engine.init(); engine.init();