From 8f04c6295e84dd7f674448b7446d9a8ba559a7dc Mon Sep 17 00:00:00 2001 From: oof1lab Date: Sat, 6 Jan 2018 10:40:24 +0000 Subject: [PATCH] #17 : cmd line option to listen to a particular ip interface of machine. --- README.md | 19 ++++++++++--------- bin/index.js | 4 ++-- index.js | 4 ++-- lib/util/cmd.helper.js | 4 +++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d54151a369..8b4485bf6b 100644 --- a/README.md +++ b/README.md @@ -862,16 +862,17 @@ http://localhost:3000/download?name=fileName ``` Options: - -V, --version output the version number - -h, --host hostname -> localhost by default - -u, --user username of database -> root by default - -p, --password password of database -> empty by default + -V, --version Output the version number + -h, --host Hostname of database -> localhost by default + -u, --user Username of database -> root by default + -p, --password Password of database -> empty by default -d, --database database schema name - -n, --portNumber port number for app -> 3000 by default - -a, --apiPrefix , api url prefix -> /api/ by default - -s, --storageFolder storage folder -> current working dir by default (available only with local) - -i, --ignoreTables comma separated table names to ignore - -h, --help output usage information + -r, --ipAddress IP interface of your server / locahost by default + -n, --portNumber Port number for app -> 3000 by default + -a, --apiPrefix Api url prefix -> /api/ by default + -s, --storageFolder Storage folder -> current working dir by default (available only with local) + -i, --ignoreTables Comma separated table names to ignore + -h, --help Output usage information Examples: diff --git a/bin/index.js b/bin/index.js index 4a50e8c536..77a205168a 100755 --- a/bin/index.js +++ b/bin/index.js @@ -42,9 +42,9 @@ let moreApis = new Xapi(sqlConfig,mysqlPool,app); moreApis.init((err, results) => { - app.listen(sqlConfig.portNumber) + app.listen(sqlConfig.portNumber,sqlConfig.ipAddress) var t1 = process.hrtime(t); - var t2 = t1[0]+t1[1]/1000000000 + var t2 = t1[0]+t1[1]/1000000000; console.log(' '); console.log(" Xmysql took : %d seconds",dataHelp.round(t2,1)); diff --git a/index.js b/index.js index 90c59a002d..3c13a04560 100644 --- a/index.js +++ b/index.js @@ -43,8 +43,8 @@ let moreApis = new Xapi(sqlConfig,mysqlPool,app); moreApis.init((err, results) => { - app.listen(sqlConfig.portNumber) - var t1 = process.hrtime(t); + app.listen(sqlConfig.portNumber,sqlConfig.ipAddress) + var t1 = process.hrtime(t) var t2 = t1[0]+t1[1]/1000000000 diff --git a/lib/util/cmd.helper.js b/lib/util/cmd.helper.js index 8cfd6408d2..302eec17df 100644 --- a/lib/util/cmd.helper.js +++ b/lib/util/cmd.helper.js @@ -12,10 +12,11 @@ program.on('--help', () => { program .version('0.4.1') - .option('-h, --host ', 'hostname / localhost by default') + .option('-h, --host ', 'hostname of database / localhost by default') .option('-u, --user ', 'username of database / root by default') .option('-p, --password ', 'password of database / empty by default') .option('-d, --database ', 'database schema name') + .option('-r, --ipAddress ', 'IP interface of your server / locahost by default') .option('-n, --portNumber ', 'port number for app / 3000 by default') .option('-s, --storageFolder ', 'storage folder / current working dir by default / available only with local') .option('-i, --ignoreTables ', 'comma separated table names to ignore') @@ -48,6 +49,7 @@ function processInvalidArguments(program) { exports.handle = program => { /**************** START : default values ****************/ + program.ipAddress = program.ipAddress || 'localhost'; program.portNumber = program.portNumber || 3000; program.user = program.user || 'root'; program.password = program.password || '';