Skip to content

Commit

Permalink
Server host config bug fix
Browse files Browse the repository at this point in the history
Server host config bug fix
  • Loading branch information
ShahanaFarooqui committed May 9, 2020
1 parent a42e76e commit d295865
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 174 deletions.
2 changes: 1 addition & 1 deletion common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ common.rtl_pass = '';
common.rtl_secret2fa = '';
common.rtl_sso = 0;
common.port = 3000;
common.host = 'localhost';
common.host = null;
common.rtl_cookie_path = '';
common.logout_redirect_link = '/login';
common.cookie = '';
Expand Down
6 changes: 4 additions & 2 deletions connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ connect.validateNodeConfig = (config) => {
common.rtl_secret2fa = config.secret2fa;
}
common.port = (process.env.PORT) ? connect.normalizePort(process.env.PORT) : (config.port) ? connect.normalizePort(config.port) : 3000;
common.host = (process.env.HOST) ? process.env.HOST : (config.host) ? config.host : 'localhost';
common.host = (process.env.HOST) ? process.env.HOST : (config.host) ? config.host : null;
if (config.nodes && config.nodes.length > 0) {
config.nodes.forEach((node, idx) => {
common.nodes[idx] = {};
Expand Down Expand Up @@ -357,7 +357,9 @@ connect.modifyJsonMultiNodeConfig = (confFileFullPath) => {
},
nodes: []
};

if (config.host) {
newConfig.host = config.host;
}
if(config.nodes && config.nodes.length > 0) {
let newNode = {};
config.nodes.forEach((node, idx) => {
Expand Down
197 changes: 36 additions & 161 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.2",
"node-sass": "^4.13.1",
"node-sass": "^4.14.1",
"nodemon": "^2.0.2",
"protractor": "^5.4.3",
"ts-node": "~7.0.0",
Expand Down
17 changes: 8 additions & 9 deletions rtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

const app = require("./app");
const common = require("./common");
const debug = require("debug")("node-angular");
const http = require("http");
var connect = require('./connect').setServerConfiguration(); //Do NOT Remove

const onError = error => {
if (error.syscall !== "listen") {
throw error;
}
const bind = typeof addr === "string" ? "pipe " + addr : "port " + common.port;
switch (error.code) {
case "EACCES":
console.error(bind + " requires elevated privileges");
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " requires elevated privileges");
process.exit(1);
break;
case "EADDRINUSE":
console.error(bind + " is already in use");
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " is already in use");
process.exit(1);
break;
case "ECONNREFUSED":
Expand All @@ -30,14 +28,15 @@ const onError = error => {
};

const onListening = () => {
const addr = server.address();
const bind = typeof addr === "string" ? "pipe " + addr : "port " + common.port;
debug("Listening on " + bind);
console.log('Server is up and running, please open the UI at http://' + common.host + ':' + common.port);
console.log('Server is up and running, please open the UI at http://' + (common.host ? common.host : 'localhost') + ':' + common.port);
};

const server = http.createServer(app);

server.on("error", onError);
server.on("listening", onListening);
server.listen(common.port, common.host);
if (common.host) {
server.listen(common.port, common.host);
} else {
server.listen(common.port);
}

0 comments on commit d295865

Please sign in to comment.