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'; webServerConfig.protocol = 'https';
} catch (e) { } 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.certOptions = {};
webServerConfig.protocol = 'http'; webServerConfig.protocol = 'http';
} }

View File

@ -100,7 +100,7 @@ class WebServer {
const self = this; const self = this;
this.events.request("services:register", 'Webserver', function (cb) { 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) { utils.checkIsAvailable(url, function (available) {
let devServer = __('Webserver') + ' (' + url + ')'; let devServer = __('Webserver') + ' (' + url + ')';
let serverStatus = (available ? 'on' : 'off'); let serverStatus = (available ? 'on' : 'off');

View File

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