@ddtcorex/dsh-maestro-supervisor 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/health-poller.js +15 -2
- package/lib/supervisor.d.ts +2 -0
- package/lib/supervisor.js +21 -3
- package/package.json +1 -1
package/lib/health-poller.js
CHANGED
|
@@ -74,8 +74,21 @@ export async function pollHealth(opts = {}) {
|
|
|
74
74
|
// (but otherwise fine) response was indistinguishable from a real crash, and
|
|
75
75
|
// combined with a low down-threshold this caused a self-sustaining restart
|
|
76
76
|
// loop (see Supervisor.downThreshold). 12s gives boot room without masking
|
|
77
|
-
// a genuinely dead process for long.
|
|
78
|
-
|
|
77
|
+
// a genuinely dead process for long. 20s (Option A 2026-09-03) tolerates
|
|
78
|
+
// high load (loadavg 12) stalls; configurable via domains.supervisor.pollTimeoutMs.
|
|
79
|
+
// If opts.timeoutMs is not injected, read from supervisor config (maestro settings).
|
|
80
|
+
let effectiveTimeout = opts.timeoutMs;
|
|
81
|
+
if (effectiveTimeout === undefined) {
|
|
82
|
+
try {
|
|
83
|
+
const { readSupervisorConfig } = await import('./config.js');
|
|
84
|
+
const cfg = await readSupervisorConfig();
|
|
85
|
+
if (typeof cfg.pollTimeoutMs === 'number' && cfg.pollTimeoutMs > 0)
|
|
86
|
+
effectiveTimeout = cfg.pollTimeoutMs;
|
|
87
|
+
}
|
|
88
|
+
catch { }
|
|
89
|
+
effectiveTimeout ??= 20000;
|
|
90
|
+
}
|
|
91
|
+
const fetchFn = opts.fetch ?? defaultFetch(opts.url ?? 'http://127.0.0.1:3080/', effectiveTimeout);
|
|
79
92
|
const psAliveFn = opts.psAlive ?? defaultPsAlive;
|
|
80
93
|
const logTailFn = opts.logTail ?? defaultLogTail;
|
|
81
94
|
let httpCode;
|
package/lib/supervisor.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export declare class Supervisor {
|
|
|
84
84
|
private getResumeWithinMs;
|
|
85
85
|
private getEffectiveIntervalMs;
|
|
86
86
|
private getEffectiveDownThreshold;
|
|
87
|
+
private getEffectiveDegradedThreshold;
|
|
88
|
+
private getEffectivePollTimeoutMs;
|
|
87
89
|
private findInterruptedRecent;
|
|
88
90
|
private collectGitDiff;
|
|
89
91
|
private attemptAutoResume;
|
package/lib/supervisor.js
CHANGED
|
@@ -211,7 +211,7 @@ export class Supervisor {
|
|
|
211
211
|
return cfg.intervalMs;
|
|
212
212
|
}
|
|
213
213
|
catch { }
|
|
214
|
-
return
|
|
214
|
+
return 5000;
|
|
215
215
|
}
|
|
216
216
|
async getEffectiveDownThreshold() {
|
|
217
217
|
if (this.deps.downThreshold !== undefined)
|
|
@@ -222,8 +222,26 @@ export class Supervisor {
|
|
|
222
222
|
return cfg.downThreshold;
|
|
223
223
|
}
|
|
224
224
|
catch { }
|
|
225
|
+
return 6;
|
|
226
|
+
}
|
|
227
|
+
async getEffectiveDegradedThreshold() {
|
|
228
|
+
try {
|
|
229
|
+
const cfg = await readSupervisorConfig();
|
|
230
|
+
if (typeof cfg.degradedThreshold === 'number' && cfg.degradedThreshold > 0)
|
|
231
|
+
return cfg.degradedThreshold;
|
|
232
|
+
}
|
|
233
|
+
catch { }
|
|
225
234
|
return 5;
|
|
226
235
|
}
|
|
236
|
+
async getEffectivePollTimeoutMs() {
|
|
237
|
+
try {
|
|
238
|
+
const cfg = await readSupervisorConfig();
|
|
239
|
+
if (typeof cfg.pollTimeoutMs === 'number' && cfg.pollTimeoutMs > 0)
|
|
240
|
+
return cfg.pollTimeoutMs;
|
|
241
|
+
}
|
|
242
|
+
catch { }
|
|
243
|
+
return 20000;
|
|
244
|
+
}
|
|
227
245
|
async findInterruptedRecent(withinMs) {
|
|
228
246
|
const ms = withinMs ?? this.getResumeWithinMs();
|
|
229
247
|
// Prefer injected mock for testability
|
|
@@ -383,8 +401,8 @@ export class Supervisor {
|
|
|
383
401
|
}
|
|
384
402
|
}
|
|
385
403
|
const now = this.deps.getTime ? this.deps.getTime() : Date.now();
|
|
386
|
-
// degraded needs
|
|
387
|
-
const degradedThreshold =
|
|
404
|
+
// degraded needs consecutive hits to avoid flapping — Option A 2026-09-03: 3→5 (via config)
|
|
405
|
+
const degradedThreshold = await this.getEffectiveDegradedThreshold();
|
|
388
406
|
this.consecutiveDegraded++;
|
|
389
407
|
if (this.consecutiveDegraded < degradedThreshold) {
|
|
390
408
|
if (now - this.lastDegradedNotify < 60000)
|
package/package.json
CHANGED