1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add -p/--port option to override listening port

This commit is contained in:
Nick O'Leary 2016-02-19 21:18:50 +00:00
parent f1377fa217
commit af736c98f2
2 changed files with 7 additions and 3 deletions

View File

@ -66,4 +66,4 @@ For more open-source projects from IBM, head over [here](http://ibm.github.io).
## Copyright and license
Copyright 2013, 2015 IBM Corp. under [the Apache 2.0 license](LICENSE).
Copyright 2013, 2016 IBM Corp. under [the Apache 2.0 license](LICENSE).

8
red.js
View File

@ -35,12 +35,14 @@ var flowFile;
var knownOpts = {
"settings":[path],
"userDir":[path],
"port": Number,
"v": Boolean,
"help": Boolean
};
var shortHands = {
"s":["--settings"],
"u":["--userDir"],
"p":["--port"],
"?":["--help"]
};
nopt.invalidHandler = function(k,v,t) {
@ -51,11 +53,13 @@ var parsedArgs = nopt(knownOpts,shortHands,process.argv,2)
if (parsedArgs.help) {
console.log("Node-RED v"+RED.version());
console.log("Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR] [flows.json]");
console.log("Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR]");
console.log(" [--port PORT] [flows.json]");
console.log("");
console.log("Options:");
console.log(" -s, --settings FILE use specified settings file");
console.log(" -u, --userDir DIR use specified user directory");
console.log(" -p, --port PORT port to listen on");
console.log(" -v enable verbose output");
console.log(" -?, --help show usage");
console.log("");
@ -153,7 +157,7 @@ if (settings.httpNodeRoot !== false) {
settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth;
}
settings.uiPort = settings.uiPort||1880;
settings.uiPort = parsedArgs.port||settings.uiPort||1880;
settings.uiHost = settings.uiHost||"0.0.0.0";
if (flowFile) {