mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-08 02:11:50 +00:00
IPC metrics
This commit is contained in:
@@ -74,3 +74,9 @@ export function arrayDistributeSequentially<T>(array: T[], count: number): T[][]
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
//region Numerics
|
||||
export function arraySum(array: number[]) {
|
||||
return array.reduce((prev, curr) => prev + curr, 0);
|
||||
}
|
||||
//endregion
|
||||
|
||||
@@ -125,7 +125,7 @@ export async function listenEvent(event: string, callback: (event: EventOpts) =>
|
||||
}
|
||||
|
||||
if (!listener) {
|
||||
listener = listener = new UnixSocketListener(path.join(process.env.EVENT_SOCKET_PATH, `${process.pid}.sock`));
|
||||
listener = new UnixSocketListener(path.join(process.env.EVENT_SOCKET_PATH, `${process.pid}.sock`));
|
||||
await listener.init();
|
||||
}
|
||||
return await listener.listen(event, callback);
|
||||
|
||||
@@ -35,7 +35,6 @@ export class UnixSocketListener extends BaseEventListener {
|
||||
isInitialized = false;
|
||||
openConnectionsMetric: Gauge.Internal<string>;
|
||||
openListenersMetric: Gauge.Internal<string>;
|
||||
isInitialized = false;
|
||||
|
||||
constructor(socketPath: string) {
|
||||
super();
|
||||
@@ -101,12 +100,12 @@ export class UnixSocketListener extends BaseEventListener {
|
||||
});
|
||||
socket.on("close", () => {
|
||||
console.log("[UnixSocketListener] Unix socket client disconnected");
|
||||
this.openConnectionsMetric.set(this.server.connections ?? 0);
|
||||
this.openConnectionsMetric.set(this.server.connections);
|
||||
});
|
||||
});
|
||||
|
||||
this.server.listen(this.socketPath, () => {
|
||||
console.log(`[UnixSocketListener] listening on ${this.socketPath}`);
|
||||
console.log(`[UnixSocketListener] Listening on ${this.socketPath}`);
|
||||
});
|
||||
|
||||
ProcessLifecycle.eventEmitter.on("stopped", async () => await this.close());
|
||||
|
||||
Reference in New Issue
Block a user