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);