From 47938bdc39adaa44f4932e219003f9b692478556 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Fri, 19 Jun 2020 09:35:10 +0200 Subject: [PATCH] fix: stats and typo, use --stats instead of --disable-stats (#10) * fix: stats and typo * add back config example * fix: use stats instead of disable-stats --- README.md | 10 +++++++--- config.js | 3 ++- docker/dockerConfig.js | 5 +++-- lib/cli.js | 18 ++++++++++++------ test/config/mongodbConfig.js | 3 ++- test/config/redisConfig.js | 3 ++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1fb0c00..f43d4eb 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,10 @@ Options: --ws-port mqtt-over-websocket server port[number] [default: 3000] --wss-port mqtt-over-secure-websocket server port [number] [default: 4000] - --disable-stats disable the publishing of stats under $SYS - [boolean] [default: true] + --stats enable publish of stats under $SYS + [boolean] [default: false] + --stats-interval interval between aedes stats pubs + [number] [default: 5000] --broker-id the id of the broker in the $SYS/ namespace [string] [default: "aedes-cli"] --config, -c the config file to use (overrides every other @@ -94,10 +96,12 @@ Options: -h, --help Show help [boolean] Examples: - aedes --proto tcp ws Starts Aedes broker with TCP and WS + aedes --protos tcp ws Starts Aedes broker with TCP and WS servers aedes --config myConfig.js Starts Aedes broker with custom config file + aedes --stats -v --statsInterval 2000 Starts Aedes broker with stats + enabled aedes --credentials ./credentials.json Add/Modify user1 with password1 to adduser user1 password1 credentials aedes --credentials ./credentials.json Removes user1 from credentials diff --git a/config.js b/config.js index 0ef13ac..5f75977 100644 --- a/config.js +++ b/config.js @@ -18,7 +18,8 @@ module.exports = { maxClientsIdLength: 23, heartbeatInterval: 60000, connectTimeout: 30000, - disableStats: true, + stats: true, + statsInterval: 5000, // PERSISTENCES persistence: null, mq: null, diff --git a/docker/dockerConfig.js b/docker/dockerConfig.js index 0ceaef8..338b5fe 100644 --- a/docker/dockerConfig.js +++ b/docker/dockerConfig.js @@ -10,7 +10,7 @@ module.exports = { cert: null, rejectUnauthorized: true, // AUTHORIZER - credentials: './credentials.json', + credentials: null, // AEDES brokerId: 'aedes-cli', concurrency: 100, @@ -18,7 +18,8 @@ module.exports = { maxClientsIdLength: 23, heartbeatInterval: 60000, connectTimeout: 30000, - disableStats: true, + stats: false, + statsInterval: 5000, // PERSISTENCES persistence: { name: 'mongodb', diff --git a/lib/cli.js b/lib/cli.js index afee727..0255ac8 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -105,10 +105,15 @@ yargs default: 4000, type: 'number' }) - .option('disable-stats', { - description: 'disable the publishing of stats under $SYS', + .option('stats', { + description: 'enable publish of stats under $SYS', type: 'boolean', - default: true + default: false + }) + .option('stats-interval', { + description: 'interval between aedes stats pubs', + default: 5000, + type: 'number' }) .option('broker-id', { description: 'the id of the broker in the $SYS/ namespace', @@ -148,8 +153,9 @@ yargs command: ['start', '$0'], describe: 'Starts Aedes broker with given options' }) - .example('aedes --proto tcp ws', 'Starts Aedes broker with TCP and WS servers') + .example('aedes --protos tcp ws', 'Starts Aedes broker with TCP and WS servers') .example('aedes --config myConfig.js', 'Starts Aedes broker with custom config file') + .example('aedes --stats -v --statsInterval 2000', 'Starts Aedes broker with stats enabled') .example('aedes --credentials ./credentials.json adduser user1 password1', 'Add/Modify user1 with password1 to credentials') .example('aedes --credentials ./credentials.json rmuser user1', 'Removes user1 from credentials') .help() @@ -399,8 +405,8 @@ async function start (program) { // STATS ------------ - if (!config.disableStats) { - stats(aedes) + if (config.stats) { + stats(broker, { interval: program.statsInterval }) } // SERVERS ------------ diff --git a/test/config/mongodbConfig.js b/test/config/mongodbConfig.js index fd1f3fd..d026fe0 100644 --- a/test/config/mongodbConfig.js +++ b/test/config/mongodbConfig.js @@ -18,7 +18,8 @@ module.exports = { maxClientsIdLength: 23, heartbeatInterval: 60000, connectTimeout: 30000, - disableStats: true, + stats: false, + statsInterval: 5000, // PERSISTENCES persistence: { name: 'mongodb', diff --git a/test/config/redisConfig.js b/test/config/redisConfig.js index f46d031..7881085 100644 --- a/test/config/redisConfig.js +++ b/test/config/redisConfig.js @@ -18,7 +18,8 @@ module.exports = { maxClientsIdLength: 23, heartbeatInterval: 60000, connectTimeout: 30000, - disableStats: true, + stats: false, + statsInterval: 5000, // PERSISTENCES persistence: { name: 'redis',