Files
NBandClaude Opus 5.5 48f6fbde69 Send Signal and TURN capacity to OpenPanel (#4114)
* Send Signal and TURN capacity to OpenPanel

A host-network sidecar reads the coturn metrics and the Signal metrics every
5 minutes and sends one signal_capacity event with counts only. Signal now
publishes its metrics on host 127.0.0.1:9642 for the sidecar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Run the capacity smoke against the real Signal server

Knip now knows the capacity-report entry, and the smoke starts the reporter
by an absolute path. The smoke uses the real Signal server with two open
sockets and checks that the reporter stops and sends nothing without the
OpenPanel client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Send only live capacity counts and deploy the reporter with Signal

coturn adds relayed bytes to its metrics only when an allocation closes, so
the traffic value did not show the live load. Remove it. Send 0 for a
transport with no allocations, read the two metric pages at the same time,
and match only the "type" label. remote:update now builds and starts the
capacity reporter with Signal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 21:24:31 +01:00

36 lines
1.7 KiB
TypeScript

import { spawn } from "node:child_process";
import { resolve } from "node:path";
const root = resolve(import.meta.dir, "../..");
const compose = ["compose", "-f", "remote/compose.yaml"];
await run("docker", [...compose, "build", "remote-api", "capacity-report", "coturn"], root);
await run("docker", [...compose, "up", "-d", "--no-build", "--no-deps", "remote-api", "capacity-report"], root);
const coturnExists = (await capture("docker", ["inspect", "openbot-coturn"], root)).code === 0;
if (coturnExists) {
console.log("Draining coturn. The update waits until all relay allocations end.");
await run("docker", ["update", "--restart=no", "openbot-coturn"], root);
await run("docker", ["kill", "--signal=SIGUSR1", "openbot-coturn"], root);
await run("docker", ["wait", "openbot-coturn"], root);
}
await run("docker", [...compose, "up", "-d", "--no-build", "--no-deps", "--force-recreate", "coturn"], root);
await run("docker", [...compose, "ps"], root);
async function run(command: string, args: string[], cwd: string): Promise<void> {
const result = await execute(command, args, cwd, "inherit");
if (result !== 0) throw new Error(`${command} failed with exit code ${result}.`);
}
async function capture(command: string, args: string[], cwd: string): Promise<{ code: number }> {
return { code: await execute(command, args, cwd, "ignore") };
}
function execute(command: string, args: string[], cwd: string, stdio: "inherit" | "ignore"): Promise<number> {
return new Promise((resolveExit, reject) => {
const child = spawn(command, args, { cwd, stdio, shell: false });
child.once("error", reject);
child.once("exit", (code) => resolveExit(code ?? 1));
});
}