Add reset-latency StartOS action

Calls POST /api/admin/reset-latency to zero the block-update latency
counters. Available while the service is running, no warning needed.
This commit is contained in:
satoshi
2026-05-11 02:18:48 +03:00
parent c925dceecc
commit cb01a16af8
2 changed files with 48 additions and 0 deletions
+8
View File
@@ -166,6 +166,14 @@ actions:
- stopped
implementation:
type: script
reset-latency:
name: "Reset Block Latency"
description: "Zeroes the block-update latency counters (avg, last, wasted work, block count). Use this after tuning ZMQ or ckpool to start fresh measurements."
warning: ~
allowed-statuses:
- running
implementation:
type: script
migrations:
from:
+40
View File
@@ -249,6 +249,46 @@ export const action: T.ExpectedExports.action = {
};
},
// ── Reset block latency ─────────────────────────────────────────────────────
"reset-latency": async (effects) => {
try {
const res = await effects.fetch(`${API_BASE}/api/admin/reset-latency`, {
method: "POST",
});
if (!res.ok) {
const body = await res.text();
return {
result: {
version: "0",
message: "Failed to reset latency stats",
value: `API returned ${res.status}: ${body}`,
copyable: false,
qr: false,
},
};
}
} catch (e) {
return {
result: {
version: "0",
message: "Failed — API unreachable",
value: `Could not reach kamado-api: ${(e as Error).message}`,
copyable: false,
qr: false,
},
};
}
return {
result: {
version: "0",
message: "Block latency stats reset to zero",
value: "All latency counters (count, avg, last, wasted work) have been cleared.\nNew measurements will accumulate from the next block.",
copyable: false,
qr: false,
},
};
},
// ── Regenerate TLS certificate ──────────────────────────────────────────────
"regen-tls-cert": async (effects) => {
const VOLUME = "main";