This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
2020-06-22 09:54:01 +00:00
|
|
|
const schedule = require("node-schedule");
|
|
|
|
const db = require("./db");
|
|
|
|
const { checks } = require("./checks");
|
|
|
|
|
|
|
|
// execute the health-check script every 5 mintues
|
|
|
|
const job = schedule.scheduleJob("*/5 * * * *", async () => {
|
|
|
|
const entry = { date: new Date().toISOString(), checks: [] };
|
|
|
|
|
|
|
|
entry.checks = await Promise.all(checks.map((check) => new Promise(check)));
|
|
|
|
|
|
|
|
db.get("entries").push(entry).write();
|
|
|
|
});
|
|
|
|
|
2020-07-30 10:00:58 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
job.invoke();
|
|
|
|
}, 60 * 1000); // delay for 60s to give other services time to start up
|