mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-27 01:48:33 +03:00
Add more to ready check
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { Server } from "http";
|
import { Server } from "http";
|
||||||
import { config } from "../config";
|
import { config } from "../config";
|
||||||
import { getRedisActiveRequests } from "../utils/redis";
|
import { getRedisActiveRequests, getRedisStats } from "../utils/redis";
|
||||||
import { Postgres } from "../databases/Postgres";
|
import { Postgres } from "../databases/Postgres";
|
||||||
import { db } from "../databases/databases";
|
import { db } from "../databases/databases";
|
||||||
|
|
||||||
@@ -11,8 +11,9 @@ export async function getReady(req: Request, res: Response, server: Server): Pro
|
|||||||
if (!connections
|
if (!connections
|
||||||
|| (connections < config.maxConnections
|
|| (connections < config.maxConnections
|
||||||
&& (!config.redis || getRedisActiveRequests() < config.redis.maxConnections * 0.8)
|
&& (!config.redis || getRedisActiveRequests() < config.redis.maxConnections * 0.8)
|
||||||
|
&& (!config.redis || getRedisStats().avgReadTime < 2000)
|
||||||
&& (!config.postgres || (db as Postgres).getStats().activeRequests < config.postgres.maxActiveRequests * 0.8))
|
&& (!config.postgres || (db as Postgres).getStats().activeRequests < config.postgres.maxActiveRequests * 0.8))
|
||||||
&& (!config.postgres || (db as Postgres).getStats().avgReadTime < 5000)) {
|
&& (!config.postgres || (db as Postgres).getStats().avgReadTime < 2000)) {
|
||||||
return res.sendStatus(200);
|
return res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
return res.sendStatus(500);
|
return res.sendStatus(500);
|
||||||
|
|||||||
Reference in New Issue
Block a user