gm-plugkit 2.0.1552 → 2.0.1554
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/package.json +1 -1
- package/supervisor.js +15 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1554",
|
|
4
4
|
"description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/supervisor.js
CHANGED
|
@@ -31,6 +31,8 @@ const POLL_INTERVAL_MS = 10_000;
|
|
|
31
31
|
const STATUS_STALE_MS = 30_000;
|
|
32
32
|
const MAX_RESTART_BURST = 5;
|
|
33
33
|
const RESTART_WINDOW_MS = 60_000;
|
|
34
|
+
const BURST_BACKOFF_MS = 60_000;
|
|
35
|
+
const VERSION_DRIFT_COOLDOWN_MS = 60_000;
|
|
34
36
|
|
|
35
37
|
function logEvent(event, fields) {
|
|
36
38
|
try {
|
|
@@ -146,6 +148,7 @@ function readShutdownReason() {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
let lastSpawnedAt = 0;
|
|
151
|
+
let lastVersionDriftActionAt = 0;
|
|
149
152
|
let restartTimestamps = [];
|
|
150
153
|
let currentChildPid = null;
|
|
151
154
|
let currentBootReason = 'initial';
|
|
@@ -155,15 +158,18 @@ function spawnWatcher(bootReason) {
|
|
|
155
158
|
restartTimestamps.push(Date.now());
|
|
156
159
|
restartTimestamps = restartTimestamps.filter(t => Date.now() - t < RESTART_WINDOW_MS);
|
|
157
160
|
if (restartTimestamps.length > MAX_RESTART_BURST) {
|
|
158
|
-
logEvent('supervisor.
|
|
161
|
+
logEvent('supervisor.restart-burst-backoff', {
|
|
159
162
|
reason: 'restart-burst-exceeded',
|
|
160
163
|
restarts_in_window: restartTimestamps.length,
|
|
161
164
|
window_ms: RESTART_WINDOW_MS,
|
|
162
165
|
max: MAX_RESTART_BURST,
|
|
163
|
-
|
|
166
|
+
backoff_ms: BURST_BACKOFF_MS,
|
|
167
|
+
severity: 'warn',
|
|
164
168
|
});
|
|
165
|
-
writeSupervisorStatus('
|
|
166
|
-
|
|
169
|
+
writeSupervisorStatus('backoff', { reason: 'restart-burst-exceeded', backoff_ms: BURST_BACKOFF_MS });
|
|
170
|
+
restartTimestamps = [];
|
|
171
|
+
setTimeout(() => spawnWatcher('post-burst-backoff'), BURST_BACKOFF_MS);
|
|
172
|
+
return;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
const primaryWrapper = path.join(os.homedir(), '.gm-tools', 'plugkit-wasm-wrapper.js');
|
|
@@ -337,10 +343,15 @@ function checkWatcherHealth() {
|
|
|
337
343
|
// On that drift, evict the stale cached wasm so the next bootstrap fails isReady() and
|
|
338
344
|
// redownloads the correct build, then recycle the child to load it.
|
|
339
345
|
if (status.version_drifted === true) {
|
|
346
|
+
if (now - lastVersionDriftActionAt < VERSION_DRIFT_COOLDOWN_MS) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
lastVersionDriftActionAt = now;
|
|
340
350
|
logEvent('supervisor.version-drift', {
|
|
341
351
|
watcher_pid: currentChildPid,
|
|
342
352
|
instance_version: status.instance_version || null,
|
|
343
353
|
file_version: status.file_version || null,
|
|
354
|
+
cooldown_ms: VERSION_DRIFT_COOLDOWN_MS,
|
|
344
355
|
severity: 'critical',
|
|
345
356
|
});
|
|
346
357
|
try {
|