diff --git a/packages/backend/scripts/check_connect.js b/packages/backend/scripts/check_connect.js index 5d6d2fca49..edfcce00b0 100644 --- a/packages/backend/scripts/check_connect.js +++ b/packages/backend/scripts/check_connect.js @@ -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); diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 551ff984b1..407694792a 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -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(); diff --git a/packages/backend/src/core/QueueModule.ts b/packages/backend/src/core/QueueModule.ts index 3fb05cda3b..e5ab015585 100644 --- a/packages/backend/src/core/QueueModule.ts +++ b/packages/backend/src/core/QueueModule.ts @@ -31,16 +31,18 @@ export type UserWebhookDeliverQueue = Bull.Queue; export type SystemWebhookDeliverQueue = Bull.Queue; function withMetrics(queue: Bull.Queue): Bull.Queue { - 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; } diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index 6fce6a6faa..15707d3050 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -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'], diff --git a/packages/backend/src/server/api/MetricsService.ts b/packages/backend/src/server/api/MetricsService.ts index 034098960d..4524bfb4ad 100644 --- a/packages/backend/src/server/api/MetricsService.ts +++ b/packages/backend/src/server/api/MetricsService.ts @@ -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(); } } diff --git a/packages/backend/test-server/entry.ts b/packages/backend/test-server/entry.ts index 04bf62d209..a6266e3440 100644 --- a/packages/backend/test-server/entry.ts +++ b/packages/backend/test-server/entry.ts @@ -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();