fix: Docker 환경 health check package.json 경로 오류 수정
require("../../package.json")이 Docker 컨테이너(/app/src/)에서
모듈을 찾지 못해 서버가 크래시하는 문제를 try-catch로 해결한다.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
29640063a8
commit
cbe3242f3a
|
|
@ -253,15 +253,26 @@ app.use("/api/", limiter);
|
|||
app.use("/api/", refreshTokenIfNeeded);
|
||||
|
||||
// 헬스 체크 엔드포인트
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { version } = require("../../package.json") as { version: string };
|
||||
let appVersion = "unknown";
|
||||
try {
|
||||
// 로컬: ../../package.json, Docker(/app/src/): ../package.json
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
appVersion = require("../../package.json").version;
|
||||
} catch {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
appVersion = require("../package.json").version;
|
||||
} catch {
|
||||
/* version stays "unknown" */
|
||||
}
|
||||
}
|
||||
app.get("/health", (req, res) => {
|
||||
res.status(200).json({
|
||||
status: "OK",
|
||||
timestamp: new Date().toISOString(),
|
||||
uptime: process.uptime(),
|
||||
environment: config.nodeEnv,
|
||||
version,
|
||||
version: appVersion,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue