Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 19d7458

Browse files
committed
fix: interval for metrics kept subprocess alive
RocketChat/Rocket.Chat#34894
1 parent 72717c1 commit 19d7458

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { writeAll } from "https://deno.land/[email protected]/io/write_all.ts";
2-
import { Queue } from "./messenger.ts";
1+
import { writeAll } from 'https://deno.land/[email protected]/io/write_all.ts';
2+
import { Queue } from './messenger.ts';
33

44
export function collectMetrics() {
55
return {
@@ -15,17 +15,3 @@ export async function sendMetrics() {
1515

1616
await writeAll(Deno.stderr, encoder.encode(JSON.stringify(metrics)));
1717
}
18-
19-
let intervalId: number;
20-
21-
export function startMetricsReport(frequencyInMs = 5000) {
22-
if (intervalId) {
23-
throw new Error('There is already an active metrics report');
24-
}
25-
26-
intervalId = setInterval(sendMetrics, frequencyInMs);
27-
}
28-
29-
export function abortMetricsReport() {
30-
clearInterval(intervalId);
31-
}

deno-runtime/main.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import apiHandler from './handlers/api-handler.ts';
2222
import handleApp from './handlers/app/handler.ts';
2323
import handleScheduler from './handlers/scheduler-handler.ts';
2424
import registerErrorListeners from './error-handlers.ts';
25-
import { startMetricsReport } from './lib/metricsCollector.ts';
26-
import { parseArgs } from './lib/parseArgs.ts';
25+
import { sendMetrics } from './lib/metricsCollector.ts';
2726

2827
type Handlers = {
2928
app: typeof handleApp;
@@ -105,7 +104,8 @@ async function main() {
105104
try {
106105
// Process PING command first as it is not JSON RPC
107106
if (message === COMMAND_PING) {
108-
Messenger.pongResponse();
107+
void Messenger.pongResponse();
108+
void sendMetrics();
109109
continue;
110110
}
111111

@@ -129,10 +129,6 @@ async function main() {
129129
}
130130
}
131131

132-
const mainArgs = parseArgs(Deno.args);
133-
134132
registerErrorListeners();
135133

136134
main();
137-
138-
startMetricsReport(mainArgs.metricsReportFrequencyInMs);

0 commit comments

Comments
 (0)