don't log metrics for postgres in testing
Some checks failed
Lint / lint (frontend-shared) (push) Blocked by required conditions
Lint / lint (misskey-bubble-game) (push) Blocked by required conditions
Lint / lint (misskey-js) (push) Blocked by required conditions
Lint / lint (misskey-reversi) (push) Blocked by required conditions
Lint / lint (sw) (push) Blocked by required conditions
Lint / typecheck (backend) (push) Blocked by required conditions
Lint / typecheck (misskey-js) (push) Blocked by required conditions
Lint / typecheck (sw) (push) Blocked by required conditions
Test (backend) / e2e (22.11.0) (push) Failing after 1m48s
Test (production install and build) / production (22.11.0) (push) Successful in 1m16s
Publish Docker image / Build (push) Successful in 5m24s
Lint / pnpm_install (pull_request) Successful in 1m31s
Test (backend) / unit (22.11.0) (push) Has been cancelled
Test (backend) / e2e (22.11.0) (pull_request) Has been cancelled
Test (backend) / unit (22.11.0) (pull_request) Has been cancelled
Lint / lint (backend) (pull_request) Has been cancelled
Lint / lint (frontend) (pull_request) Has been cancelled
Lint / lint (frontend-embed) (pull_request) Has been cancelled
Lint / lint (frontend-shared) (pull_request) Has been cancelled
Lint / lint (misskey-bubble-game) (pull_request) Has been cancelled
Lint / lint (misskey-js) (pull_request) Has been cancelled
Lint / lint (misskey-reversi) (pull_request) Has been cancelled
Lint / lint (sw) (pull_request) Has been cancelled
Lint / typecheck (backend) (pull_request) Has been cancelled
Lint / typecheck (misskey-js) (pull_request) Has been cancelled
Lint / typecheck (sw) (pull_request) Has been cancelled
Lint / pnpm_install (push) Has been cancelled
Lint / lint (backend) (push) Has been cancelled
Lint / lint (frontend) (push) Has been cancelled
Lint / lint (frontend-embed) (push) Has been cancelled
Publish Docker image / Build (pull_request) Has been cancelled
Test (production install and build) / production (22.11.0) (pull_request) Has been cancelled

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-17 06:01:25 -06:00
parent 4d44adfaa9
commit 5961d29a11
No known key found for this signature in database
6 changed files with 24 additions and 25 deletions

View file

@ -7,11 +7,6 @@ import Redis from 'ioredis';
import { loadConfig } from '../built/config.js';
import { createPostgresDataSource } from '../built/postgres.js';
const timeout = setTimeout(() => {
console.error('Timeout while connecting to databases.');
process.exit(1);
}, 120000);
const config = loadConfig();
async function connectToPostgres() {
@ -59,5 +54,3 @@ const promises = Array
]);
await Promise.allSettled(promises);
clearTimeout(timeout);

View file

@ -43,6 +43,12 @@ mBuildInfo.set({
node_version: process.version
}, 1);
const mStartupTime = new prom.Gauge({
name: 'misskey_startup_time',
help: 'Misskey startup time',
labelNames: ['pid']
});
function greet() {
if (!envOption.quiet) {
//#region Misskey logo
@ -112,6 +118,8 @@ export async function masterMain() {
});
}
mStartupTime.set({ pid: process.pid }, Date.now());
if (envOption.disableClustering) {
if (envOption.onlyServer) {
await server();

View file

@ -31,16 +31,18 @@ export type UserWebhookDeliverQueue = Bull.Queue<UserWebhookDeliverJobData>;
export type SystemWebhookDeliverQueue = Bull.Queue<SystemWebhookDeliverJobData>;
function withMetrics<T>(queue: Bull.Queue<T>): Bull.Queue<T> {
setInterval(async () => {
mActiveJobs.set({ queue: queue.name }, await queue.getActiveCount());
mDelayedJobs.set({ queue: queue.name }, await queue.getDelayedCount());
mWaitingJobs.set({ queue: queue.name }, await queue.getWaitingCount());
}, 2000);
queue.on('waiting', () => {
mJobReceivedCounter.inc({ queue: queue.name });
});
if (process.env.NODE_ENV !== 'test') {
setInterval(async () => {
mActiveJobs.set({ queue: queue.name }, await queue.getActiveCount());
mDelayedJobs.set({ queue: queue.name }, await queue.getDelayedCount());
mWaitingJobs.set({ queue: queue.name }, await queue.getWaitingCount());
}, 2000);
queue.on('waiting', () => {
mJobReceivedCounter.inc({ queue: queue.name });
});
}
return queue;
}

View file

@ -342,7 +342,8 @@ export function createPostgresDataSource(config: Config, isMain = false) {
},
} : false,
logging: log ? 'all' : ['query'],
logger: (isMain || log) ? new MyCustomLogger(!log) : undefined,
logger: process.env.NODE_ENV === 'test' ? undefined :
(isMain || log) ? new MyCustomLogger(!log) : undefined,
maxQueryExecutionTime: 500,
entities: entities,
migrations: ['../../migration/*.js'],

View file

@ -18,7 +18,7 @@ export class MetricsService {
) {}
@bindThis
public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) {
public createServer(fastify: FastifyInstance) {
if (this.config.prometheusMetrics?.enable) {
const token = this.config.prometheusMetrics.scrapeToken;
fastify.get('/metrics', async (request, reply) => {
@ -46,7 +46,5 @@ export class MetricsService {
}
});
}
done();
}
}

View file

@ -5,7 +5,6 @@ import { NestFactory } from '@nestjs/core';
import { MainModule } from '@/MainModule.js';
import { ServerService } from '@/server/ServerService.js';
import { loadConfig } from '@/config.js';
import { NestLogger } from '@/NestLogger.js';
import { INestApplicationContext } from '@nestjs/common';
const config = loadConfig();
@ -22,10 +21,8 @@ let serverService: ServerService;
async function launch() {
await killTestServer();
console.log('starting application...');
app = await NestFactory.createApplicationContext(MainModule, {
logger: new NestLogger(),
logger: ["debug", "log", "error", "warn", "verbose"],
});
serverService = app.get(ServerService);
await serverService.launch();
@ -84,7 +81,7 @@ async function startControllerEndpoints(port = config.port + 1000) {
console.log('starting application...');
app = await NestFactory.createApplicationContext(MainModule, {
logger: new NestLogger(),
logger: ["debug", "log", "error", "warn", "verbose"],
});
serverService = app.get(ServerService);
await serverService.launch();