Adds log for missing webserver cert and minor fixes

This commit is contained in:
Praveen Gupta 2018-12-05 00:14:25 +05:30 committed by Iuri Matias
parent 26d66f6e09
commit ca358b4622
3 changed files with 10 additions and 14 deletions

View File

@ -483,6 +483,8 @@ Config.prototype.loadWebServerConfigFile = function() {
};
webServerConfig.protocol = 'https';
} catch (e) {
this.logger.error(e.message);
this.logger.warn('Invalid path for key/cert in config/webserver.js. Using http instead.');
webServerConfig.certOptions = {};
webServerConfig.protocol = 'http';
}

View File

@ -100,7 +100,7 @@ class WebServer {
const self = this;
this.events.request("services:register", 'Webserver', function (cb) {
let url = this.protocol + '://' + canonicalHost(self.host) + ':' + self.port;
let url = self.protocol + '://' + canonicalHost(self.host) + ':' + self.port;
utils.checkIsAvailable(url, function (available) {
let devServer = __('Webserver') + ' (' + url + ')';
let serverStatus = (available ? 'on' : 'off');

View File

@ -32,19 +32,13 @@ function recursiveMerge(target, source) {
function checkIsAvailable(url, callback) {
const protocol = url.split(':')[0];
if (protocol === 'http') {
http.get(url, function (_res) {
callback(true);
}).on('error', function (_res) {
callback(false);
});
} else if (protocol === 'https') {
https.get(url, function (_res) {
callback(true);
}).on('error', function (_res) {
callback(false);
});
}
const httpObj = (protocol === 'https') ? https : http;
httpObj.get(url, function (_res) {
callback(true);
}).on('error', function (_res) {
callback(false);
});
}
function httpGetRequest(httpObj, url, callback) {