blob: 6bfa4ffb1018e0b360cb6bf02ce228da9f8aa896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import { NextResponse } from 'next/server';
export async function GET() {
try {
// Oracle DB 연결 테스트
let oracleStatus = 'unknown';
let oracleError = null;
try {
const { oracleKnex } = await import('@/lib/oracle-db/db');
const result = await oracleKnex.raw('SELECT 1 FROM DUAL');
oracleStatus = result ? 'connected' : 'disconnected';
} catch (error) {
oracleStatus = 'disconnected';
oracleError = error instanceof Error ? error.message : String(error);
}
// PostgreSQL 연결 테스트
let postgresStatus = 'unknown';
let postgresError = null;
try {
const db = await import('@/db/db');
await db.default.execute('SELECT 1');
postgresStatus = 'connected';
} catch (error) {
postgresStatus = 'disconnected';
postgresError = error instanceof Error ? error.message : String(error);
}
// 전체 상태 판단
const overallStatus = oracleStatus === 'connected' && postgresStatus === 'connected'
? 'healthy'
: 'unhealthy';
return NextResponse.json({
status: overallStatus,
timestamp: new Date().toISOString(),
databases: {
oracle: {
status: oracleStatus,
error: oracleError
},
postgres: {
status: postgresStatus,
error: postgresError
}
},
environment: {
nodeEnv: process.env.NODE_ENV,
runtime: process.env.NEXT_RUNTIME || 'nodejs'
}
});
} catch (error) {
console.error('Health check error:', error);
return NextResponse.json({
status: 'error',
timestamp: new Date().toISOString(),
error: error instanceof Error ? error.message : String(error)
}, { status: 500 });
}
}
|