mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow port zero for Express (#1363)
* Allow uiPort to be 0 (i.e. distinguish from undefined). When Express runs up, catch the real port number to settings.serverPort, and use that in getListenPath if set, else use uiPort.
This commit is contained in:
parent
a42e99c4aa
commit
b81940351f
19
red.js
19
red.js
@ -167,7 +167,16 @@ if (settings.httpNodeRoot !== false) {
|
|||||||
settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth;
|
settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.uiPort = parsedArgs.port||settings.uiPort||1880;
|
// if we got a port from command line, use it (even if 0)
|
||||||
|
// replicate (settings.uiPort = parsedArgs.port||settings.uiPort||1880;) but allow zero
|
||||||
|
if (parsedArgs.port !== undefined){
|
||||||
|
settings.uiPort = parsedArgs.port;
|
||||||
|
} else {
|
||||||
|
if (settings.uiPort === undefined){
|
||||||
|
settings.uiPort = 1880;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
settings.uiHost = settings.uiHost||"0.0.0.0";
|
settings.uiHost = settings.uiHost||"0.0.0.0";
|
||||||
|
|
||||||
if (flowFile) {
|
if (flowFile) {
|
||||||
@ -261,9 +270,14 @@ if (settings.httpStatic) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getListenPath() {
|
function getListenPath() {
|
||||||
|
var port = settings.serverPort;
|
||||||
|
if (port === undefined){
|
||||||
|
port = settings.uiPort;
|
||||||
|
}
|
||||||
|
|
||||||
var listenPath = 'http'+(settings.https?'s':'')+'://'+
|
var listenPath = 'http'+(settings.https?'s':'')+'://'+
|
||||||
(settings.uiHost == '0.0.0.0'?'127.0.0.1':settings.uiHost)+
|
(settings.uiHost == '0.0.0.0'?'127.0.0.1':settings.uiHost)+
|
||||||
':'+settings.uiPort;
|
':'+port;
|
||||||
if (settings.httpAdminRoot !== false) {
|
if (settings.httpAdminRoot !== false) {
|
||||||
listenPath += settings.httpAdminRoot;
|
listenPath += settings.httpAdminRoot;
|
||||||
} else if (settings.httpStatic) {
|
} else if (settings.httpStatic) {
|
||||||
@ -292,6 +306,7 @@ RED.start().then(function() {
|
|||||||
if (settings.httpAdminRoot === false) {
|
if (settings.httpAdminRoot === false) {
|
||||||
RED.log.info(RED.log._("server.admin-ui-disabled"));
|
RED.log.info(RED.log._("server.admin-ui-disabled"));
|
||||||
}
|
}
|
||||||
|
settings.serverPort = server.address().port;
|
||||||
process.title = parsedArgs.title || 'node-red';
|
process.title = parsedArgs.title || 'node-red';
|
||||||
RED.log.info(RED.log._("server.now-running", {listenpath:getListenPath()}));
|
RED.log.info(RED.log._("server.now-running", {listenpath:getListenPath()}));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user