fix: 배포 헬스체크를 로그 기반 완료 신호 감지 방식으로 변경#196
Conversation
기존 방식(15초 대기 + 10회x10초 폴링)은 OTel agent 계측으로 부팅 시간이
늘어나면서(3s→20~30s) 정상 배포도 실패로 오판하는 문제가 있었음.
이제 프로세스 생존 여부로 진짜 실패(크래시)를 즉시 감지하고, 살아있는 동안은
Spring Boot가 실제로 찍는 완료 로그("Started ServerApplication")를 기다림.
임의의 타임아웃 추측 대신 실제 이벤트 기반 판단이라 부팅 시간 변동에 안전하고,
5분 상한선은 진짜 행(hang) 상황에 대한 안전장치로만 남김.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDeployment startup now uses a log-based readiness signal, monitors process liveness for failures, enforces a 240-second timeout, and performs one health check after readiness succeeds. ChangesDeployment readiness
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
scripts/deploy.sh (1)
33-41: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winUnbounded log growth from switching to append mode.
LOG_FILEis now appended (>> "$LOG_FILE") instead of truncated, needed to trackSTART_LINEfor readiness detection. Over many deploys with no rotation,nohup.outwill grow indefinitely (worse with OTel agent output) and can eventually fill disk on the instance.Also,
LOG_FILEre-hardcodes/home/ec2-user/app/nohup.outeven thoughAPP_DIR=/home/ec2-user/appis already defined and the scriptcds into it — considerLOG_FILE="$APP_DIR/nohup.out"for consistency.♻️ Suggested tweaks
-LOG_FILE=/home/ec2-user/app/nohup.out +LOG_FILE="$APP_DIR/nohup.out" START_LINE=$(wc -l < "$LOG_FILE" 2>/dev/null || echo 0)Add basic rotation (e.g., via
logrotateconfig fornohup.out, or truncate/archive it on each deploy onceSTART_LINEbookkeeping is no longer needed for the previous run).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/deploy.sh` around lines 33 - 41, Update the deployment script’s LOG_FILE to derive from APP_DIR instead of hard-coding the application path, and add basic nohup.out rotation or archival before appending new output. Preserve START_LINE-based readiness detection by rotating only when the previous run’s log bookkeeping is no longer needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/deploy.sh`:
- Around line 75-77: Update the health-check curl invocation in the deployment
script to include an explicit request timeout, ensuring an unavailable or
unresponsive actuator endpoint cannot block indefinitely. Keep the existing
health response logging behavior and do not change deployment success gating.
- Around line 43-73: Reduce MAX_WAIT in the readiness loop to leave sufficient
time below the AppSpec hook’s 300-second timeout for the earlier shutdown delay,
health check, and cleanup diagnostics; use a margin such as 240–270 seconds
while preserving the existing timeout failure path and 5-minute overall
hang-protection intent.
---
Nitpick comments:
In `@scripts/deploy.sh`:
- Around line 33-41: Update the deployment script’s LOG_FILE to derive from
APP_DIR instead of hard-coding the application path, and add basic nohup.out
rotation or archival before appending new output. Preserve START_LINE-based
readiness detection by rotating only when the previous run’s log bookkeeping is
no longer needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
- MAX_WAIT을 appspec.yml의 AfterInstall 훅 타임아웃(300초)과 정확히 일치시키지 않고 240초로 낮춰서, CodeDeploy의 외부 강제종료가 스크립트 자체의 정상 종료 로직보다 먼저 발동하지 않도록 여유 확보 - 헬스체크 curl에 --max-time 10 추가, 포트가 아직 안 열려있을 때 무한 대기하지 않도록 방어
작업 배경
변경 사항
scripts/deploy.shStarted ServerApplication) 감지 방식으로 교체영향 범위
Test Plan
bash -n scripts/deploy.sh문법 검증🤖 Generated with Claude Code
Summary by CodeRabbit