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

add --title for process name to command line options

This commit is contained in:
Dave Conway-Jones 2016-11-17 13:57:33 +00:00
parent eeea8e530e
commit 361ff315e9

36
red.js
View File

@ -33,17 +33,20 @@ var settingsFile;
var flowFile; var flowFile;
var knownOpts = { var knownOpts = {
"settings":[path], "help": Boolean,
"userDir":[path],
"port": Number, "port": Number,
"v": Boolean, "settings": [path],
"help": Boolean "title": String,
"userDir": [path],
"verbose": Boolean
}; };
var shortHands = { var shortHands = {
"s":["--settings"], "?":["--help"],
"u":["--userDir"],
"p":["--port"], "p":["--port"],
"?":["--help"] "s":["--settings"],
"t":["--help"],
"u":["--userDir"],
"v":["--verbose"]
}; };
nopt.invalidHandler = function(k,v,t) { nopt.invalidHandler = function(k,v,t) {
// TODO: console.log(k,v,t); // TODO: console.log(k,v,t);
@ -54,14 +57,15 @@ var parsedArgs = nopt(knownOpts,shortHands,process.argv,2)
if (parsedArgs.help) { if (parsedArgs.help) {
console.log("Node-RED v"+RED.version()); console.log("Node-RED v"+RED.version());
console.log("Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR]"); console.log("Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR]");
console.log(" [--port PORT] [flows.json]"); console.log(" [--port PORT] [--title TITLE] [flows.json]");
console.log(""); console.log("");
console.log("Options:"); 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(" -p, --port PORT port to listen on");
console.log(" -v enable verbose output"); console.log(" -s, --settings FILE use specified settings file");
console.log(" -?, --help show usage"); console.log(" --title TITLE process window title");
console.log(" -u, --userDir DIR use specified user directory");
console.log(" -v, --verbose enable verbose output");
console.log(" -?, --help show this help");
console.log(""); console.log("");
console.log("Documentation can be found at http://nodered.org"); console.log("Documentation can be found at http://nodered.org");
process.exit(); process.exit();
@ -121,9 +125,9 @@ if (parsedArgs.v) {
} }
if (settings.https) { if (settings.https) {
server = https.createServer(settings.https,function(req,res){app(req,res);}); server = https.createServer(settings.https,function(req,res) {app(req,res);});
} else { } else {
server = http.createServer(function(req,res){app(req,res);}); server = http.createServer(function(req,res) {app(req,res);});
} }
server.setMaxListeners(0); server.setMaxListeners(0);
@ -224,7 +228,6 @@ if (settings.httpNodeRoot !== false && settings.httpNodeAuth) {
if (settings.httpNodeRoot !== false) { if (settings.httpNodeRoot !== false) {
app.use(settings.httpNodeRoot,RED.httpNode); app.use(settings.httpNodeRoot,RED.httpNode);
} }
if (settings.httpStatic) { if (settings.httpStatic) {
settings.httpStaticAuth = settings.httpStaticAuth || settings.httpAuth; settings.httpStaticAuth = settings.httpStaticAuth || settings.httpAuth;
if (settings.httpStaticAuth) { if (settings.httpStaticAuth) {
@ -265,7 +268,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"));
} }
process.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()}));
}); });
} else { } else {
@ -280,7 +283,6 @@ RED.start().then(function() {
} }
}); });
process.on('uncaughtException',function(err) { process.on('uncaughtException',function(err) {
util.log('[red] Uncaught Exception:'); util.log('[red] Uncaught Exception:');
if (err.stack) { if (err.stack) {