diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-22 14:02:09 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-22 14:02:09 +1000 |
commit | c273dacd7a8d079eb130560f32f7c9acc486f98c (patch) | |
tree | 2965f99e81eca3e747bda514c0c4c9469fdd8282 | |
parent | Do measurements one at a time in order (diff) | |
download | server-c273dacd7a8d079eb130560f32f7c9acc486f98c.tar.xz |
Disable gateway status until I get some like child process thing done
-rw-r--r-- | slowcord/status/src/index.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/slowcord/status/src/index.ts b/slowcord/status/src/index.ts index 1ef062a1..390767ac 100644 --- a/slowcord/status/src/index.ts +++ b/slowcord/status/src/index.ts @@ -7,6 +7,7 @@ const dbConn = mysql.createConnection(process.env.DATABASE as string); const executePromise = (sql: string, args: any[]) => new Promise((resolve, reject) => dbConn.execute(sql, args, (err, res) => { if (err) reject(err); else resolve(res); })); const instance = { + app: process.env.INSTANCE_WEB_APP as string, api: process.env.INSTANCE_API as string, cdn: process.env.INSTANCE_CDN as string, token: process.env.INSTANCE_TOKEN as string, @@ -48,7 +49,7 @@ const savePerf = async (time: number, name: string, error: string | null) => { } }; -const measureApi = async (name: string, path: string, body?: object) => { +const measureApi = async (name: string, path: string, isJson?: boolean, body?: object) => { const start = Date.now(); let error: Error | null = null; @@ -60,7 +61,7 @@ const measureApi = async (name: string, path: string, body?: object) => { }, body: body ? JSON.stringify(body) : undefined, }); - await res.json(); + if (isJson !== false) await res.json(); } catch (e) { error = e as Error; @@ -75,14 +76,15 @@ const measureApi = async (name: string, path: string, body?: object) => { const app = async () => { await new Promise((resolve) => dbConn.connect(resolve)); console.log("Connected to db"); - await client.login(instance.token); + // await client.login(instance.token); console.log(`Monitoring performance for instance at ${new URL(instance.api).hostname}`); const doMeasurements = async () => { await measureApi("ping", `${instance.api}/ping`); await measureApi("users/@me", `${instance.api}/users/@me`); - await gatewayMeasure("websocketPing"); + await measureApi("login", `${instance.app}/login`, false); + // await gatewayMeasure("websocketPing"); setTimeout(doMeasurements, parseInt(process.env.MEASURE_INTERVAL as string)); }; |