feat(backend): also check meilisearch status if available

This commit is contained in:
Acid Chicken (硫酸鶏) 2024-05-19 19:56:03 +09:00
parent 6edcde9c4e
commit bda337db4a
No known key found for this signature in database
GPG Key ID: 3E87B98A3F6BAB99
1 changed files with 5 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import { bindThis } from '@/decorators.js';
import { DI } from '@/di-symbols.js';
import { readyRef } from '@/boot/ready.js';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
import type { MeiliSearch } from 'meilisearch';
@Injectable()
export class HealthServerService {
@ -23,6 +24,9 @@ export class HealthServerService {
@Inject(DI.db)
private db: DataSource,
@Inject(DI.meilisearch)
private meilisearch: MeiliSearch | null,
) {}
@bindThis
@ -35,6 +39,7 @@ export class HealthServerService {
this.redisForSub.ping(),
this.redisForTimelines.ping(),
this.db.query('SELECT 1'),
...(this.meilisearch ? [this.meilisearch.health()] : []),
]).then(() => 200, () => 503));
});