feat(system): process heartbeat + /system/health, engine runs business fields (W9-I)
- process_heartbeat / process_heartbeat_sample (0034): api / worker / worker:agent / all
upsert every 15s (event loop lag last/max, concurrency, running runs, SSE connections, memory)
- GET /system/health (admin): processes with 45s stale flag, SSE, DB latency/size/connections,
disks (DATA_DIR / library roots / download dirs, cache thresholds), mount sentinel checks
with IO timeout, engine pending/oldest/24h failure rate, schedules
- GET /system/health/history?hours=: bucketed lag / running / SSE series
- /engine/runs and /engine/runs/{id}: business {kind, refId, title, triggeredBy} joined from
run input / task / agent_run / tasks_run_meta / outbox; businessKind / businessRefId filters
- docs/runbook/ops.md: field meanings and alert thresholds
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
46d37d87fe
commit
e8745115f4
17 files changed
+1789
-4
No files matched your search
@@ -75,6 +75,12 @@ export class EventBus implements EventBusPort {
|
||||
|
||||
const SINCE_PAGE = 500;
|
||||
|
||||
/** 本进程当前打开的 SSE 流数(进程与健康页用;不含 JSON 补读请求) */
|
||||
let openStreams = 0;
|
||||
export function sseConnectionCount(): number {
|
||||
return openStreams;
|
||||
}
|
||||
|
||||
export interface SseOptions {
|
||||
bus: EventBusPort;
|
||||
keepaliveMs?: number;
|
||||
@@ -135,6 +141,13 @@ export function sseRoutes({ bus, keepaliveMs = 15_000 }: SseOptions) {
|
||||
}
|
||||
|
||||
return streamSSE(c, async (stream) => {
|
||||
openStreams += 1;
|
||||
let counted = true;
|
||||
const release = () => {
|
||||
if (counted) openStreams = Math.max(0, openStreams - 1);
|
||||
counted = false;
|
||||
};
|
||||
stream.onAbort(release);
|
||||
const queue: EventEnvelope[] = [];
|
||||
let wake: (() => void) | null = null;
|
||||
// 先订阅再读缓冲,避免两者之间的事件丢失
|
||||
@@ -185,6 +198,7 @@ export function sseRoutes({ bus, keepaliveMs = 15_000 }: SseOptions) {
|
||||
} finally {
|
||||
clearInterval(timer);
|
||||
unsubscribe();
|
||||
release();
|
||||
}
|
||||
});
|
||||
}) as never);
|
||||
|
||||
Reference in new issue
Block a user