mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-31 20:04:36 +00:00
*/Server.ts: Handle metrics requests
This commit is contained in:
@@ -53,6 +53,7 @@ export class SpacebarServer extends Server {
|
||||
|
||||
async start() {
|
||||
await Monitoring.init();
|
||||
Monitoring.attach(this.app);
|
||||
await initDatabase();
|
||||
await Config.init();
|
||||
await initEvent();
|
||||
|
||||
@@ -37,6 +37,7 @@ export class CDNServer extends Server {
|
||||
|
||||
async start() {
|
||||
await Monitoring.init();
|
||||
Monitoring.attach(this.app);
|
||||
await initDatabase();
|
||||
await Config.init();
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import * as client from "prom-client";
|
||||
import { Router } from "express";
|
||||
import http, { IncomingMessage, ServerResponse } from "node:http";
|
||||
|
||||
export class Monitoring {
|
||||
static isInitialised = false;
|
||||
@@ -35,4 +36,9 @@ export class Monitoring {
|
||||
res.send(metrics);
|
||||
});
|
||||
}
|
||||
|
||||
static async handleRawRequest(req: IncomingMessage, res: ServerResponse) {
|
||||
const metrics = await client.register.metrics();
|
||||
res.setHeader("Content-Type", client.register.contentType).writeHead(200).end(metrics);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user