redis 제거
This commit is contained in:
@@ -2,8 +2,6 @@ import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { InjectDataSource } from '@nestjs/typeorm';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { InjectRedis } from '@nestjs-modules/ioredis';
|
||||
import Redis from 'ioredis';
|
||||
|
||||
export interface SystemHealthResponse {
|
||||
status: 'ok' | 'error';
|
||||
@@ -17,12 +15,6 @@ export interface SystemHealthResponse {
|
||||
status: 'connected' | 'disconnected';
|
||||
error?: string;
|
||||
};
|
||||
redis: {
|
||||
host: string;
|
||||
port: number;
|
||||
status: 'connected' | 'disconnected';
|
||||
error?: string;
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@@ -30,19 +22,16 @@ export class SystemService {
|
||||
constructor(
|
||||
private configService: ConfigService,
|
||||
@InjectDataSource() private dataSource: DataSource,
|
||||
@InjectRedis() private redis: Redis,
|
||||
) {}
|
||||
|
||||
async getHealth(): Promise<SystemHealthResponse> {
|
||||
const dbHealth = await this.checkDatabase();
|
||||
const redisHealth = await this.checkRedis();
|
||||
|
||||
return {
|
||||
status: dbHealth.status === 'connected' && redisHealth.status === 'connected' ? 'ok' : 'error',
|
||||
status: dbHealth.status === 'connected' ? 'ok' : 'error',
|
||||
timestamp: new Date().toISOString(),
|
||||
environment: this.configService.get('NODE_ENV') || 'development',
|
||||
database: dbHealth,
|
||||
redis: redisHealth,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,29 +50,4 @@ export class SystemService {
|
||||
return { ...config, status: 'disconnected' as const, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
private async checkRedis() {
|
||||
const redisUrl = this.configService.get('REDIS_URL') || '';
|
||||
let host = this.configService.get('REDIS_HOST') || 'unknown';
|
||||
let port = parseInt(this.configService.get('REDIS_PORT')) || 6379;
|
||||
|
||||
if (redisUrl) {
|
||||
try {
|
||||
const url = new URL(redisUrl);
|
||||
host = url.hostname;
|
||||
port = parseInt(url.port) || 6379;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
try {
|
||||
const pong = await this.redis.ping();
|
||||
return {
|
||||
host,
|
||||
port,
|
||||
status: pong === 'PONG' ? 'connected' as const : 'disconnected' as const,
|
||||
};
|
||||
} catch (error) {
|
||||
return { host, port, status: 'disconnected' as const, error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user