From cf23abdc8977acf3b4e5c46bfcf7f043012addd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Sander?= Date: Fri, 21 Aug 2020 10:05:44 +0200 Subject: [PATCH] Implements #54, optional Docker healthcheck --- docker-healthcheck.js | 3 ++- index.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docker-healthcheck.js b/docker-healthcheck.js index d3d353d..0b74c75 100755 --- a/docker-healthcheck.js +++ b/docker-healthcheck.js @@ -1,8 +1,9 @@ +const config = require('config'); var httpHealth = require("http"); var optionsHealth = { host : "localhost", - port : "12398", + port : config.get('dockerHealthCheck.port'), timeout : 2000 }; diff --git a/index.js b/index.js index 6030b56..250ca2d 100755 --- a/index.js +++ b/index.js @@ -131,6 +131,7 @@ restServer.listen(config.get('restAPIPort'), function() { logger.info(`${restServer.name} listening at ${restServer.url}`); }); + // Set up Docker healthcheck server // Create restServer object var restServerDockerHealth = restify.createServer({ @@ -138,6 +139,7 @@ var restServerDockerHealth = restify.createServer({ version: appVersion, }); + // Enable parsing of http parameters restServerDockerHealth.use(restify.plugins.queryParser()); @@ -154,10 +156,15 @@ restServerDockerHealth.get( }, ); -// Start Docker healthcheck REST server on port 12398 -restServerDockerHealth.listen(12398, function() { - logger.info(`Docker healthcheck server now listening on ${restServerDockerHealth.url}`); -}); +// Start Docker healthcheck REST server on port set in config file +if (config.get('dockerHealthCheck.enabled') == true) { + logger.verbose('MAIN: Starting Docker healthcheck server...'); + + restServerDockerHealth.listen(config.get('dockerHealthCheck.port'), function () { + logger.info(`Docker healthcheck server now listening on ${restServerDockerHealth.url}`); + }); +}; + // Create custom property (unless it already exists) used to identify template apps let qrsInstanceCustomPropertyCheck1 = new qrsInteract(configQRS);