add support for website config file; reflect real web server config in the dashboard

This commit is contained in:
Iuri Matias 2017-03-04 14:20:28 -05:00
parent 269552aee0
commit 85659987d9
6 changed files with 35 additions and 3 deletions

View File

@ -0,0 +1,5 @@
{
"enabled": true,
"host": "localhost",
"port": 8000
}

View File

@ -0,0 +1,5 @@
{
"enabled": true,
"host": "localhost",
"port": 8000
}

View File

@ -9,6 +9,7 @@ var Config = function(options) {
this.blockchainConfig = {};
this.contractsConfig = {};
this.pipelineConfig = {};
this.webServerConfig = {};
this.chainTracker = {};
this.assetFiles = {};
this.contractsFiles = [];
@ -46,6 +47,7 @@ Config.prototype.loadConfigFiles = function(options) {
this.loadPipelineConfigFile();
this.loadContractsConfigFile();
this.loadWebServerConfigFile();
this.loadChainTrackerFile();
this.loadPluginContractFiles();
};
@ -148,6 +150,16 @@ Config.prototype.loadCommunicationConfigFile = function() {
}
};
Config.prototype.loadWebServerConfigFile = function() {
var webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json");
var defaultWebConfig = {
"enabled": true,
"host": "localhost",
"port": 8000
};
this.webServerConfig = utils.recursiveMerge(defaultWebConfig, webServerConfigJSON);
};
Config.prototype.loadEmbarkConfigFile = function() {
var contracts = this.embarkConfig.contracts;
this.contractsFiles = this.loadFiles(contracts);

View File

@ -130,11 +130,13 @@ Engine.prototype.fileWatchService = function(options) {
};
Engine.prototype.webServerService = function(options) {
var webServerConfig = this.config.webServerConfig;
if (!webServerConfig.enabled) { return; }
this.logger.setStatus("Starting Server");
var server = new Server({
logger: this.logger,
host: options.serverHost,
port: options.serverPort
host: options.serverHost || webServerConfig.host,
port: options.serverPor || webServerConfig.port
});
server.start(function(){});
};

View File

@ -3,6 +3,7 @@ var async = require('async');
var http = require('http');
var utils = require('./utils.js');
// TODO: needs a refactor and be done in a different way
var ServicesMonitor = function(options) {
this.logger = options.logger;
this.interval = options.interval || 5000;
@ -92,8 +93,10 @@ ServicesMonitor.prototype.check = function() {
});
},
function checkDevServer(result, callback) {
var host = self.config.webServerConfig.host || self.serverHost;
var port = self.config.webServerConfig.port || self.serverPort;
self.logger.trace('checkDevServer');
var devServer = 'Webserver (http://' + self.serverHost + ':' + self.serverPort + ')';
var devServer = 'Webserver (http://' + host + ':' + port + ')';
devServer = (self.runWebserver) ? devServer.green : devServer.red;
result.push(devServer);
callback(null, result);

View File

@ -0,0 +1,5 @@
{
"enabled": true,
"host": "localhost",
"port": 8001
}