From 2fd70550cde69e1ee69d43529b04f8423ddbdb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Sander?= Date: Sat, 27 May 2023 15:29:08 +0000 Subject: [PATCH] feat: log at startup which config file is used feat: log at startup current API rate limit --- .github/workflows/release-please.yml | 4 ---- .vscode/launch.json | 4 ++-- src/app.js | 4 ++++ src/butler.js | 1 + src/config/production_template.yaml | 2 +- src/docker-healthcheck.js | 2 ++ src/globals.js | 7 +++++++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 5425f7be..7055ca9f 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -70,10 +70,6 @@ jobs: node butler.js -c ./config/config-gen-api-docs.yaml --no-qs-connection & sleep 20 echo "...1" - curl localhost:8081/documentation/json - echo "...2" - curl localhost:8081/documentation/yaml - echo "...3" curl localhost:8081/documentation/json > ../docs/api_doc/butler-api.json echo "...4" curl localhost:8081/documentation/yaml > ../docs/api_doc/butler-api.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json index a491df23..229a5612 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,8 +16,8 @@ "NODE_ENV": "production" }, "args": [ - // "--configfile", - // "config/production.yaml", + "--configfile", + "config/production.yaml", // "--new-relic-account-name", // "'First NR account'", // "--new-relic-account-id", diff --git a/src/app.js b/src/app.js index 598e239a..52501a96 100644 --- a/src/app.js +++ b/src/app.js @@ -86,6 +86,10 @@ async function build(opts = {}) { globals.logger.info(`Cores : ${globals.hostInfo.si.cpu.cores}`); globals.logger.info(`Docker arch. : ${globals.hostInfo.si.cpu.hypervizor}`); globals.logger.info(`Total memory : ${globals.hostInfo.si.memory.total}`); + globals.logger.info(''); + // Add log line with name of config file + globals.logger.info(`Config file : ${globals.configFileExpanded}`); + globals.logger.info(`API rate limit : ${globals.options.apiRateLimit}`); globals.logger.info('--------------------------------------'); // Log info about what Qlik Sense certificates are being used diff --git a/src/butler.js b/src/butler.js index 06fe8bec..f96852d3 100644 --- a/src/butler.js +++ b/src/butler.js @@ -6,6 +6,7 @@ const dgram = require('dgram'); const globals = require('./globals'); const serviceMonitor = require('./lib/service_monitor'); +// The build function creates a new instance of the App class and returns it. const build = require('./app'); const udp = require('./udp'); diff --git a/src/config/production_template.yaml b/src/config/production_template.yaml index 345c9cd9..e2d143af 100644 --- a/src/config/production_template.yaml +++ b/src/config/production_template.yaml @@ -653,7 +653,7 @@ Butler: enable: true # Main on/off switch for service monitoring frequency: every 30 seconds # https://bunkat.github.io/later/parsers.html monitor: - - host: emo # Host name of Windows computer where services are running + - host: # Host name of Windows computer where services are running services: # List of services to monitor - postgresql-x64-12 # Posgress/repository db - QlikSenseEngineService diff --git a/src/docker-healthcheck.js b/src/docker-healthcheck.js index f67cbed8..b6d890d0 100644 --- a/src/docker-healthcheck.js +++ b/src/docker-healthcheck.js @@ -9,6 +9,8 @@ const optionsHealth = { timeout: 2000, }; +// This code checks the health of the docker container using the docker api +// It checks the status code of the response and returns an exit code of 0 if the response is 200 and 1 otherwise const requestHealth = httpHealth.request(optionsHealth, (res) => { console.log(`STATUS Docker health: ${res.statusCode}`); if (res.statusCode === 200) { diff --git a/src/globals.js b/src/globals.js index 03c021af..b1a3060a 100644 --- a/src/globals.js +++ b/src/globals.js @@ -88,6 +88,12 @@ if (options.configfile && options.configfile.length > 0) { console.log('Error: Specified config file does not exist'); process.exit(1); } +} else { + // Get value of env variable NODE_ENV + const env = process.env.NODE_ENV; + + // Get path to config file + configFileExpanded = upath.resolve(__dirname, `./config/${env}.yaml`); } // Are we running as standalone app or not? @@ -586,6 +592,7 @@ async function initHostInfo() { module.exports = { config, configEngine, + configFileExpanded, configQRS, teamsTaskFailureObj, teamsTaskAbortedObj,