Добавлены cli-параметры --host, --port
This commit is contained in:
@@ -34,7 +34,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
server: {
|
server: {
|
||||||
ip: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: '22380',
|
port: '22380',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ let log;
|
|||||||
let config;
|
let config;
|
||||||
let argv;
|
let argv;
|
||||||
let branch = '';
|
let branch = '';
|
||||||
const argvStrings = ['lib-dir', 'app-dir', 'inpx'];
|
const argvStrings = ['host', 'port', 'app-dir', 'lib-dir', 'inpx'];
|
||||||
|
|
||||||
function showHelp() {
|
function showHelp() {
|
||||||
console.log(utils.versionText(config));
|
console.log(utils.versionText(config));
|
||||||
@@ -23,6 +23,8 @@ function showHelp() {
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print ${config.name} command line options
|
--help Print ${config.name} command line options
|
||||||
|
--host=<ip> Set web server host, default: 0.0.0.0
|
||||||
|
--port=<port> Set web server port, default: 22380
|
||||||
--app-dir=<dirpath> Set application working directory, default: <execDir>/.${config.name}
|
--app-dir=<dirpath> Set application working directory, default: <execDir>/.${config.name}
|
||||||
--lib-dir=<dirpath> Set library directory, default: the same as ${config.name} executable's
|
--lib-dir=<dirpath> Set library directory, default: the same as ${config.name} executable's
|
||||||
--inpx=<filepath> Set INPX collection file, default: the one that found in library dir
|
--inpx=<filepath> Set INPX collection file, default: the one that found in library dir
|
||||||
@@ -66,6 +68,14 @@ async function init() {
|
|||||||
log('Initializing');
|
log('Initializing');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.host) {
|
||||||
|
config.server.host = argv.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.port) {
|
||||||
|
config.server.port = argv.port;
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.remoteLib) {
|
if (!config.remoteLib) {
|
||||||
const libDir = argv['lib-dir'];
|
const libDir = argv['lib-dir'];
|
||||||
if (libDir) {
|
if (libDir) {
|
||||||
@@ -154,8 +164,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const serverConfig = config.server;
|
const serverConfig = config.server;
|
||||||
server.listen(serverConfig.port, serverConfig.ip, () => {
|
server.listen(serverConfig.port, serverConfig.host, () => {
|
||||||
log(`Server is ready on http://${serverConfig.ip}:${serverConfig.port}`);
|
log(`Server is ready on http://${serverConfig.host}:${serverConfig.port}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user