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);
|
app.use("/api/", refreshTokenIfNeeded);
|
||||||
|
|
||||||
// 헬스 체크 엔드포인트
|
// 헬스 체크 엔드포인트
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
let appVersion = "unknown";
|
||||||
const { version } = require("../../package.json") as { version: string };
|
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) => {
|
app.get("/health", (req, res) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: "OK",
|
status: "OK",
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
uptime: process.uptime(),
|
uptime: process.uptime(),
|
||||||
environment: config.nodeEnv,
|
environment: config.nodeEnv,
|
||||||
version,
|
version: appVersion,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue