From dc7eca9e3d383efa41e9eec6e2841b961de4fa9f Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 9 Oct 2022 20:55:42 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20cli-=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D1=8B=20--host,=20--port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/config/base.js | 2 +- server/index.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/config/base.js b/server/config/base.js index 3882f40..df298e8 100644 --- a/server/config/base.js +++ b/server/config/base.js @@ -34,7 +34,7 @@ module.exports = { */ server: { - ip: '0.0.0.0', + host: '0.0.0.0', port: '22380', }, }; diff --git a/server/index.js b/server/index.js index 3e2cf9a..5952946 100644 --- a/server/index.js +++ b/server/index.js @@ -14,7 +14,7 @@ let log; let config; let argv; let branch = ''; -const argvStrings = ['lib-dir', 'app-dir', 'inpx']; +const argvStrings = ['host', 'port', 'app-dir', 'lib-dir', 'inpx']; function showHelp() { console.log(utils.versionText(config)); @@ -23,6 +23,8 @@ function showHelp() { Options: --help Print ${config.name} command line options + --host= Set web server host, default: 0.0.0.0 + --port= Set web server port, default: 22380 --app-dir= Set application working directory, default: /.${config.name} --lib-dir= Set library directory, default: the same as ${config.name} executable's --inpx= Set INPX collection file, default: the one that found in library dir @@ -66,6 +68,14 @@ async function init() { log('Initializing'); } + if (argv.host) { + config.server.host = argv.host; + } + + if (argv.port) { + config.server.port = argv.port; + } + if (!config.remoteLib) { const libDir = argv['lib-dir']; if (libDir) { @@ -154,8 +164,8 @@ async function main() { } const serverConfig = config.server; - server.listen(serverConfig.port, serverConfig.ip, () => { - log(`Server is ready on http://${serverConfig.ip}:${serverConfig.port}`); + server.listen(serverConfig.port, serverConfig.host, () => { + log(`Server is ready on http://${serverConfig.host}:${serverConfig.port}`); }); }