fix(fleet): heartbeat consistency — MOSAIC_HOME path + configurable interval (#595)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #595.
This commit is contained in:
@@ -368,6 +368,16 @@ export function buildAgentTailCommand(
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const HEARTBEAT_INTERVAL_MS = 15_000;
|
||||
|
||||
/**
|
||||
* Heartbeat interval in ms, honoring MOSAIC_HEARTBEAT_INTERVAL (seconds) so the
|
||||
* `fleet ps` freshness threshold matches the writer sidecar's actual cadence
|
||||
* (start-agent-session.sh). Falls back to HEARTBEAT_INTERVAL_MS (15s).
|
||||
*/
|
||||
export function heartbeatIntervalMs(): number {
|
||||
const sec = Number.parseInt(process.env.MOSAIC_HEARTBEAT_INTERVAL ?? '', 10);
|
||||
return Number.isFinite(sec) && sec > 0 ? sec * 1000 : HEARTBEAT_INTERVAL_MS;
|
||||
}
|
||||
export const HEARTBEAT_HEALTHY_MULTIPLIER = 3;
|
||||
|
||||
export interface HeartbeatInfo {
|
||||
@@ -496,7 +506,7 @@ export function parseHeartbeat(content: string | null, nowMs = Date.now()): Hear
|
||||
status = val;
|
||||
}
|
||||
}
|
||||
const thresholdMs = HEARTBEAT_INTERVAL_MS * HEARTBEAT_HEALTHY_MULTIPLIER;
|
||||
const thresholdMs = heartbeatIntervalMs() * HEARTBEAT_HEALTHY_MULTIPLIER;
|
||||
let health: 'healthy' | 'stale' | 'unknown' = 'unknown';
|
||||
let ageMs: number | null = null;
|
||||
if (ts !== null) {
|
||||
|
||||
Reference in New Issue
Block a user