add support for website config file; reflect real web server config in the dashboard
This commit is contained in:
parent
269552aee0
commit
85659987d9
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"enabled": true,
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 8000
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"enabled": true,
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 8000
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ var Config = function(options) {
|
||||||
this.blockchainConfig = {};
|
this.blockchainConfig = {};
|
||||||
this.contractsConfig = {};
|
this.contractsConfig = {};
|
||||||
this.pipelineConfig = {};
|
this.pipelineConfig = {};
|
||||||
|
this.webServerConfig = {};
|
||||||
this.chainTracker = {};
|
this.chainTracker = {};
|
||||||
this.assetFiles = {};
|
this.assetFiles = {};
|
||||||
this.contractsFiles = [];
|
this.contractsFiles = [];
|
||||||
|
@ -46,6 +47,7 @@ Config.prototype.loadConfigFiles = function(options) {
|
||||||
this.loadPipelineConfigFile();
|
this.loadPipelineConfigFile();
|
||||||
|
|
||||||
this.loadContractsConfigFile();
|
this.loadContractsConfigFile();
|
||||||
|
this.loadWebServerConfigFile();
|
||||||
this.loadChainTrackerFile();
|
this.loadChainTrackerFile();
|
||||||
this.loadPluginContractFiles();
|
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() {
|
Config.prototype.loadEmbarkConfigFile = function() {
|
||||||
var contracts = this.embarkConfig.contracts;
|
var contracts = this.embarkConfig.contracts;
|
||||||
this.contractsFiles = this.loadFiles(contracts);
|
this.contractsFiles = this.loadFiles(contracts);
|
||||||
|
|
|
@ -130,11 +130,13 @@ Engine.prototype.fileWatchService = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.webServerService = function(options) {
|
Engine.prototype.webServerService = function(options) {
|
||||||
|
var webServerConfig = this.config.webServerConfig;
|
||||||
|
if (!webServerConfig.enabled) { return; }
|
||||||
this.logger.setStatus("Starting Server");
|
this.logger.setStatus("Starting Server");
|
||||||
var server = new Server({
|
var server = new Server({
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
host: options.serverHost,
|
host: options.serverHost || webServerConfig.host,
|
||||||
port: options.serverPort
|
port: options.serverPor || webServerConfig.port
|
||||||
});
|
});
|
||||||
server.start(function(){});
|
server.start(function(){});
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ var async = require('async');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var utils = require('./utils.js');
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
|
// TODO: needs a refactor and be done in a different way
|
||||||
var ServicesMonitor = function(options) {
|
var ServicesMonitor = function(options) {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.interval = options.interval || 5000;
|
this.interval = options.interval || 5000;
|
||||||
|
@ -92,8 +93,10 @@ ServicesMonitor.prototype.check = function() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function checkDevServer(result, callback) {
|
function checkDevServer(result, callback) {
|
||||||
|
var host = self.config.webServerConfig.host || self.serverHost;
|
||||||
|
var port = self.config.webServerConfig.port || self.serverPort;
|
||||||
self.logger.trace('checkDevServer');
|
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;
|
devServer = (self.runWebserver) ? devServer.green : devServer.red;
|
||||||
result.push(devServer);
|
result.push(devServer);
|
||||||
callback(null, result);
|
callback(null, result);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"enabled": true,
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 8001
|
||||||
|
}
|
Loading…
Reference in New Issue