mirror of https://github.com/embarklabs/embark.git
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.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);
|
||||
|
|
|
@ -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(){});
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
"port": 8001
|
||||
}
|
Loading…
Reference in New Issue