Added influx checkHealth
This commit is contained in:
parent
354ca32a61
commit
fc5900b0ba
26
src/helper/influx-checks.js
Normal file
26
src/helper/influx-checks.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const logger = require("./helper/logger.js")("influx-checks");
|
||||||
|
|
||||||
|
const Influx = require('@influxdata/influxdb-client-apis');
|
||||||
|
|
||||||
|
|
||||||
|
function checkHealth(influxDb){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
new Influx.HealthAPI(influxDb) // Check influx health
|
||||||
|
.getHealth()
|
||||||
|
.catch((err) => {
|
||||||
|
logger.fatal("Could not communicate with Influx:");
|
||||||
|
logger.fatal(`Error [${err.code}]:`, err.message);
|
||||||
|
reject(err);
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
logger.debug("Server healthy.", "Version: ", res.version);
|
||||||
|
resolve(res);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Specify exports
|
||||||
|
module.exports = {
|
||||||
|
checkHealth,
|
||||||
|
};
|
@ -25,4 +25,8 @@ if(errorMsg){
|
|||||||
logger.info("Setup Influx..");
|
logger.info("Setup Influx..");
|
||||||
const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
|
const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
|
||||||
|
|
||||||
|
await InfluxChecks.checkHealth(influxDb)
|
||||||
|
.catch(exit(1))
|
||||||
|
.then((res) => {});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user