Merge pull request #405 from NebulousLabs/healthcheck-cli-fix
update db before reading it in api
This commit is contained in:
commit
97e312f75a
|
@ -6,6 +6,7 @@ if (!process.env.PORTAL_URL) {
|
|||
|
||||
const express = require("express");
|
||||
const bodyparser = require("body-parser");
|
||||
const db = require("./db");
|
||||
|
||||
require("./schedule");
|
||||
|
||||
|
@ -16,6 +17,10 @@ const server = express();
|
|||
|
||||
server.use(bodyparser.urlencoded({ extended: false }));
|
||||
server.use(bodyparser.json());
|
||||
server.use((req, res, next) => {
|
||||
db.read();
|
||||
next();
|
||||
});
|
||||
|
||||
server.get("/health-check", require("./api/index"));
|
||||
server.get("/health-check/critical", require("./api/critical"));
|
||||
|
|
|
@ -10,7 +10,7 @@ const criticalJob = schedule.scheduleJob("*/5 * * * *", async () => {
|
|||
checks: await Promise.all(criticalChecks.map((check) => new Promise(check))),
|
||||
};
|
||||
|
||||
db.get("critical").push(entry).write();
|
||||
db.read().get("critical").push(entry).write();
|
||||
});
|
||||
|
||||
// execute the verbose health-check script once per hour
|
||||
|
@ -20,7 +20,7 @@ const verboseJob = schedule.scheduleJob("0 * * * *", async () => {
|
|||
checks: await Promise.all(verboseChecks.map((check) => new Promise(check))),
|
||||
};
|
||||
|
||||
db.get("verbose").push(entry).write();
|
||||
db.read().get("verbose").push(entry).write();
|
||||
});
|
||||
|
||||
// Launch Health check jobs
|
||||
|
|
Reference in New Issue