This commit is contained in:
talorr
2026-03-27 03:36:08 +03:00
parent 8a97ce6d54
commit cda36918e8
225 changed files with 35641 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
const fs = require('fs');
const config = require('../src/config');
try {
const raw = fs.readFileSync(config.heartbeatFile, 'utf8');
const heartbeat = JSON.parse(raw);
const ageMs = Date.now() - new Date(heartbeat.timestamp).getTime();
const maxAgeMs = Math.max(config.pollIntervalMs * 3, 120000);
if (!heartbeat.timestamp || Number.isNaN(ageMs) || ageMs > maxAgeMs) {
console.error('Heartbeat is stale');
process.exit(1);
}
if (heartbeat.status === 'fatal') {
console.error('Parser is in fatal state');
process.exit(1);
}
process.exit(0);
} catch (error) {
console.error(error.message);
process.exit(1);
}