Node.js
fetch, plus a wrapper for scheduled scripts.
fetch (Node 18+)
const PING = "https://vivere.dev/p/<monitor-id>";
async function ping(suffix = "", body) {
try {
await fetch(PING + suffix, { method: "POST", body, signal: AbortSignal.timeout(10_000) });
} catch {} // never let monitoring break the job
}
await ping("/start");
try {
await runJob();
await ping("", "job ok");
} catch (err) {
await ping("/fail", String(err.stack ?? err).slice(-16000));
process.exitCode = 1;
}
node-cron
import cron from "node-cron";
cron.schedule("*/10 * * * *", async () => {
await ping("/start");
try { await sync(); await ping(); } catch (e) { await ping("/fail", String(e)); }
});
Give the monitor the same expression, */10 * * * *, and a grace of a few minutes.