mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
fix: host imports running a defaults pass and metrics restart per host (#1384)
This commit is contained in:
1 parent
5e31642379
commit
11a22d30eb
6 files changed
+76
-10
No files matched your search
@@ -22,6 +22,8 @@ export interface MetricsViewersV1 {
|
||||
unregister: (hostId: number, viewerSessionId: string) => void;
|
||||
}
|
||||
|
||||
const RETIME_DEBOUNCE_MS = 1000;
|
||||
|
||||
export async function activate(ctx: PluginContext) {
|
||||
const log = createLogger(ctx.log);
|
||||
const repository = await createHostMetricsRepository(ctx.db);
|
||||
@@ -73,7 +75,19 @@ export async function activate(ctx: PluginContext) {
|
||||
const { hostId } = payload as { hostId?: number };
|
||||
if (hostId) poller.hostKeyAccepted(hostId);
|
||||
});
|
||||
ctx.settings.onChange("metricsInterval", () => void poller.retimeAll());
|
||||
// An import writes this once per host, and each write restarted every
|
||||
// polled host. One retime after the writes settle covers them all.
|
||||
let retime: ReturnType<typeof setTimeout> | null = null;
|
||||
ctx.settings.onChange("metricsInterval", () => {
|
||||
if (retime) clearTimeout(retime);
|
||||
retime = setTimeout(() => {
|
||||
retime = null;
|
||||
void poller.retimeAll();
|
||||
}, RETIME_DEBOUNCE_MS);
|
||||
});
|
||||
ctx.disposables.add(() => {
|
||||
if (retime) clearTimeout(retime);
|
||||
});
|
||||
|
||||
ctx.services.provide<MetricsViewersV1>("host-metrics.viewers", {
|
||||
register: async (hostId) => {
|
||||
|
||||
Reference in new issue
Block a user