Skip to content

[WTH-378] Caddy 설정 수정#75

Merged
hyxklee merged 4 commits into
devfrom
fix/WTH-378-Caddy-reload시-반영이-안되는-문제
May 22, 2026

Hidden character warning

The head ref may contain hidden characters: "fix/WTH-378-Caddy-reload\uc2dc-\ubc18\uc601\uc774-\uc548\ub418\ub294-\ubb38\uc81c"
Merged

[WTH-378] Caddy 설정 수정#75
hyxklee merged 4 commits into
devfrom
fix/WTH-378-Caddy-reload시-반영이-안되는-문제

Conversation

@hyxklee
Copy link
Copy Markdown
Contributor

@hyxklee hyxklee commented May 18, 2026

📌 Summary

어떤 작업인지 한 줄 요약해 주세요.

Caddy 설정을 일부 수정했습니다

📝 Changes

변경사항을 what, why, how로 구분해 작성해 주세요.

What

""

Why

  • SSE가 동작하지 않는 문제 발생
  • 블루/그린 배포시 변경된 포트가 적용되지 않는 문제 발생

How

  • /stream 엔드포인트에서는 압축을 사용하지 않도록 수정
  • 배포 스크립트에서 Caddy 설정을 일부 수정해 reload -> 검사 -> restart가 될 수 있도록 변경

📸 Screenshots / Logs

필요시 스크린샷 or 로그를 첨부해주세요.

💡 Reviewer 참고사항

리뷰에 참고할 내용을 작성해주세요.

✅ Checklist

  • PR 제목 설정 완료 (WTH-123 인증 필터 설정)
  • 테스트 구현 완료
  • 리뷰어 등록 완료
  • 자체 코드 리뷰 완료

Summary by CodeRabbit

  • 개선 사항
    • 스트리밍(SSE) 응답에 대해 압축을 제외하고, 캐시 제어 및 버퍼링 관련 헤더를 추가하여 스트리밍 지연/버퍼링 개선
    • 배포 헬스체크를 환경변수로 제어하는 데드라인 기반 루프로 변경하고, 헬스 실패 시 새 컨테이너를 즉시 중지·정리
    • 설정 반영을 검증하는 재로드 검증 로직을 도입하여 재로드 실패 혹은 새 업스트림 미반영 시 안전하게 재시작으로 폴백
    • 배포 관련 문서의 헬스체크 기준을 최신화

Review Change Stack

@hyxklee hyxklee requested a review from soo0711 May 18, 2026 07:03
@hyxklee hyxklee self-assigned this May 18, 2026
@hyxklee hyxklee added the 🐞 BugFix 버그 수정 label May 18, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddbf047c-11f5-454a-8f37-3da660724d9f

📥 Commits

Reviewing files that changed from the base of the PR and between 3bfb522 and 6a6dc77.

📒 Files selected for processing (2)
  • infra/dev/scripts/deploy.sh
  • infra/prod/scripts/deploy.sh

📝 Walkthrough

워크스루

개발·운영 Caddy 설정에서 /stream SSE를 압축/버퍼링 대상에서 제외하고 관련 헤더를 추가했으며, 배포 스크립트들은 헬스체크를 데드라인 기반으로 바꾸고 caddy reload 반영을 admin API로 검증하도록 개선했습니다.

변경사항

Caddy SSE 스트림 설정 및 배포 검증

Layer / File(s) Summary
Caddy SSE 스트림 설정
infra/dev/caddy/Caddyfile, infra/prod/caddy/Caddyfile
/stream$ 경로를 매칭하는 @sseStream 요청 매처와 @notSseStream을 정의하고, encode@notSseStream에만 적용합니다. SSE 응답에는 Cache-Control: "no-cache, no-transform"X-Accel-Buffering: "no" 헤더를 추가합니다.
배포 스크립트 (개발)
infra/dev/scripts/deploy.sh, README.md
헬스체크를 제어하는 HEALTH_CHECK_* 환경변수를 추가하고 데드라인 기반 폴링으로 변경합니다. caddy reload 출력을 캡처해 Caddy admin API(/config/)에서 weeth-dev-app-${NEW_COLOR}:8080 업스트림 반영을 검증하며, 반영 실패 또는 reload 실패 시 재시작으로 폴백합니다.
배포 스크립트 (운영)
infra/prod/scripts/deploy.sh
헬스체크 기본값을 추가하고 데드라인 기반 루프로 전환합니다. caddy reload의 성공 판정을 admin API를 통해 새 upstream 반영 여부로 변경하고, 미반영 또는 실패 시 docker compose restart caddy로 폴백합니다.

Sequence Diagram

sequenceDiagram
  participant Deploy as deploy.sh
  participant DockerExec as docker compose exec caddy
  participant CaddyAdmin as Caddy Admin API /config/

  Deploy->>DockerExec: caddy reload (capture output)
  DockerExec-->>Deploy: reload_output, exit code
  Deploy->>CaddyAdmin: caddy wget /config/
  CaddyAdmin-->>Deploy: config JSON
  alt new upstream present
    Deploy->>Deploy: reload_ok=true -> "caddy reloaded"
  else not present or reload failed
    Deploy->>Deploy: reload_ok=false -> "falling back to restart"
    Deploy->>DockerExec: docker compose restart caddy
  end
Loading

예상 코드 리뷰 노력

🎯 4 (Complex) | ⏱️ ~45 minutes

관련 PR

  • Team-Weeth/weeth-server#70: deploy.sh의 caddy reload 실패/재시작 분기 관련 변경과 연관됩니다.
  • Team-Weeth/weeth-server#69: infra/*/scripts/deploy.sh의 헬스체크 및 reload/업스트림 검증 관련 변경과 직접적으로 관련됩니다.
  • Team-Weeth/weeth-server#46: 배포시 caddy 관련 결정 로직을 수정한 점에서 코드 수준 연관이 있습니다.

추천 라벨

🌏 Deploy

추천 리뷰어

  • soo0711

스트림은 조용히 흘러가고,
토끼는 새 배포를 살피네.
Caddy는 헤더를 속삭이며,
헬스체크는 시간을 재고,
배포는 증거로 안정을 찾네. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 제목 'WTH-378 Caddy 설정 수정'은 변경사항의 주요 부분(Caddy 설정 수정)을 언급하지만, 실제 핵심 변경(SSE 압축 제외, 배포 스크립트 개선)을 구체적으로 설명하지 못하고 있습니다.
Description check ✅ Passed 설명서는 기본 구조를 따르고 주요 변경사항(What, Why, How)을 포함하지만, What 섹션이 비어있고 Reviewer 참고사항이 없어 완전성이 떨어집니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/WTH-378-Caddy-reload시-반영이-안되는-문제

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator

@soo0711 soo0711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨씁니다~!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@infra/dev/scripts/deploy.sh`:
- Around line 44-63: The health-check loop can exit naturally when SECONDS >
health_check_deadline and skip the error handling; fix by detecting timeout
after the loop or by using a success flag: introduce a boolean (e.g.,
success=false) before the while using health_check_deadline and set success=true
only when the curl check succeeds (where you currently echo "[deploy] new app is
healthy" and break), then after the loop check if success is false or if SECONDS
is greater than or equal to health_check_deadline and in that case run the
existing failure cleanup (docker compose stop/rm and exit 1); reference symbols:
health_check_deadline, SECONDS, HEALTH_CHECK_TIMEOUT_SECONDS, curl invocation,
sleep, and the docker compose stop/rm/exit 1 block.

In `@infra/prod/scripts/deploy.sh`:
- Around line 44-63: The health-check loop exits silently if sleep pushes
SECONDS past health_check_deadline, skipping the failure cleanup; update the
logic in the loop that uses health_check_deadline and SECONDS (the while [
"$SECONDS" -le "$health_check_deadline" ] loop and the sleep
"$HEALTH_CHECK_INTERVAL_SECONDS" line) to ensure the timeout path always runs:
either change the loop to while true and perform the timeout check (the if [
"$SECONDS" -ge "$health_check_deadline" ] block that stops/rms "app-$NEW_COLOR"
via docker compose) after each sleep, or keep the loop condition but add a
post-loop check that runs the same docker compose stop/rm + exit 1 when SECONDS
>= health_check_deadline; mirror the exact fix applied to the dev script so the
curl health check to "http://127.0.0.1:${NEW_HEALTH_PORT}/actuator/health"
reliably triggers the cleanup on timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ef39e3e-df5e-4be9-8f2b-82a6a6e38f6d

📥 Commits

Reviewing files that changed from the base of the PR and between 1ed2e43 and 3bfb522.

📒 Files selected for processing (3)
  • README.md
  • infra/dev/scripts/deploy.sh
  • infra/prod/scripts/deploy.sh
✅ Files skipped from review due to trivial changes (1)
  • README.md

Comment thread infra/dev/scripts/deploy.sh
Comment thread infra/prod/scripts/deploy.sh
@hyxklee hyxklee merged commit 87a7cb9 into dev May 22, 2026
2 checks passed
@hyxklee hyxklee deleted the fix/WTH-378-Caddy-reload시-반영이-안되는-문제 branch May 22, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants