EXPERIMENTAL: new stats logic
Release rolling / release (push) Successful in 8m29s

This commit is contained in:
Raven Scott
2026-08-04 21:47:32 -04:00
parent ab6cea96c7
commit a9e2b54c70
13 changed files with 931 additions and 154 deletions
+29
View File
@@ -15,6 +15,12 @@ import {
upsertSchedule,
deleteSchedule,
} from '../services/schedules.js'
import {
getStatsConfig,
updateStatsConfig,
getStatsFilePath,
STATS_LIMITS,
} from '../services/stats.js'
import logger from '../utils/logger.js'
/** @type {Map<string, { username: string, serveraddress?: string }>} */
@@ -181,6 +187,29 @@ export function registerSystemHandlers(session) {
return getMetricsSnapshot({ peerCount: peers.size })
})
/**
* Docker stats collection knobs (Settings → Performance).
* Viewer can read; only admin can update (see updateStatsConfig).
*/
session.respond('getStatsConfig', async () => {
return {
success: true,
config: getStatsConfig(),
meta: { limits: STATS_LIMITS, path: getStatsFilePath() },
}
})
session.respond('updateStatsConfig', async (args = {}) => {
const replace = Boolean(args.replace)
const partial =
args.config && typeof args.config === 'object' ? args.config : args
const config = updateStatsConfig(partial, {
replace,
persist: args.persist !== false,
})
return { success: true, config }
})
session.respond('listSchedules', async () => {
return { success: true, schedules: listSchedules() }
})