This commit is contained in:
@@ -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() }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user