mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix relay connections metrics
This commit is contained in:
parent
5ac1abdf69
commit
950adb25c6
1 changed files with 5 additions and 1 deletions
|
|
@ -28,9 +28,11 @@ const limiter = new TTLCache<string, number>();
|
|||
|
||||
/** Set up the Websocket connection. */
|
||||
function connectStream(socket: WebSocket, ip: string | undefined) {
|
||||
let opened = false;
|
||||
const controllers = new Map<string, AbortController>();
|
||||
|
||||
socket.onopen = () => {
|
||||
opened = true;
|
||||
relayConnectionsGauge.inc();
|
||||
};
|
||||
|
||||
|
|
@ -61,7 +63,9 @@ function connectStream(socket: WebSocket, ip: string | undefined) {
|
|||
};
|
||||
|
||||
socket.onclose = () => {
|
||||
if (opened) {
|
||||
relayConnectionsGauge.dec();
|
||||
}
|
||||
|
||||
for (const controller of controllers.values()) {
|
||||
controller.abort();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue