Skip to content

Fix: CodeDeploy 로그 출력 경로 명시#366

Merged
rlagkswn00 merged 1 commit intodevelopfrom
fix/issue-289-codedeploy-stdout
Mar 30, 2026
Merged

Fix: CodeDeploy 로그 출력 경로 명시#366
rlagkswn00 merged 1 commit intodevelopfrom
fix/issue-289-codedeploy-stdout

Conversation

@rlagkswn00
Copy link
Copy Markdown
Member

@rlagkswn00 rlagkswn00 commented Mar 27, 2026

#️⃣ 이슈

📌 요약

  • 배포 스크립트에서 애플리케이션 stdout/stderr 출력 파일을 명시적으로 지정했습니다.
  • 배포 후 런타임 로그가 기본 nohup.out에 암묵적으로 쌓이던 상태를 application.log로 고정해 운영 중 로그 확인 경로를 분명히 했습니다.

🛠️ 상세

  • scripts/start.sh에 APP_LOG=/home/ec2-user/app/application.log 변수를 추가했습니다.
  • nohup java -jar ... 실행 시 stdout/stderr를 application.log로 리다이렉트하도록 변경했습니다.
  • deploy.log는 배포 단계 로그로 유지하고, 애플리케이션 실행 로그는 별도 파일로 분리했습니다.

💬 기타

  • 테스트는 실행하지 않았습니다. 쉘 스크립트 변경만 포함됩니다.
  • 이 변경은 로그 출력 위치를 명시적으로 고정하는 수정입니다. CodeDeploy 실패 원인 자체를 직접 해결하는지 여부는 배포 환경 로그로 추가 확인이 필요합니다.
  • 기존 nohup.out 대신 application.log를 확인해야 합니다.

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 애플리케이션 시작 시 표준 출력과 오류를 application.log 파일로 리다이렉트하도록 업데이트했습니다. 이를 통해 애플리케이션 로그가 파일에 저장되어 더욱 체계적인 로그 관리가 가능해졌습니다.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Walkthrough

scripts/start.sh의 Spring JAR 시작 명령을 수정하여 표준 출력과 표준 오류를 새로운 application.log 파일로 리다이렉트하도록 변경했습니다. APP_LOG 변수를 추가하고 nohup 명령에 로그 파일 경로를 통합했습니다.

Changes

Cohort / File(s) 요약
로깅 구성
scripts/start.sh
Spring JAR 시작 명령에 표준 출력/표준 오류 리다이렉션 추가. APP_LOG 변수($PROJECT_ROOT/application.log)를 정의하고 > "$APP_LOG" 2>&1을 통해 로그 파일로 출력을 리다이렉트하도록 수정. 표준 입력은 /dev/null로 분리 유지.

Poem

🐰 로그 파일로 흐르는 메시지들,
이제 파일에 담겨 기록되고,
시작의 순간을 영원히 간직하네—
우리의 애플리케이션 일지, 반짝반짝! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 내용과 명확하게 일치합니다. 스크립트의 로그 출력 경로를 명시적으로 지정하는 변경 사항을 정확하게 설명하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/issue-289-codedeploy-stdout

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

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/start.sh`:
- Line 22: The nohup invocation currently uses overwrite redirection (">") which
discards previous logs; update the launch in scripts/start.sh to append instead
(use ">>" for "$APP_LOG") or add a pre-start rotation/backup step that moves or
archives the existing "$APP_LOG" before running nohup with JAR_FILE so
historical logs (crash traces) are preserved; update the nohup line and/or add a
short rotation block referencing APP_LOG and JAR_FILE accordingly.
🪄 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: 24816817-4789-4de5-9f1c-330e10f887d1

📥 Commits

Reviewing files that changed from the base of the PR and between c55817f and 1bb5678.

📒 Files selected for processing (1)
  • scripts/start.sh

Comment thread scripts/start.sh
chmod 755 $JAR_FILE
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG
nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE &
nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE > "$APP_LOG" 2>&1 < /dev/null &
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 27, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

재시작 시 이전 로그 손실 가능성

> 리다이렉션은 파일을 덮어쓰므로 애플리케이션 재시작 시 이전 실행의 로그(크래시 원인 등)가 손실됩니다. >>를 사용하여 append 모드로 변경하거나, 시작 전 로그 백업/로테이션 로직 추가를 권장합니다.

🔧 Append 모드로 변경 제안
-nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE > "$APP_LOG" 2>&1 < /dev/null &
+nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE >> "$APP_LOG" 2>&1 < /dev/null &

또는 시작 전 로테이션 로직 추가:

# 시작 전 기존 로그 백업 (선택적)
if [ -f "$APP_LOG" ]; then
  mv "$APP_LOG" "$APP_LOG.$(date +%Y%m%d_%H%M%S)"
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/start.sh` at line 22, The nohup invocation currently uses overwrite
redirection (">") which discards previous logs; update the launch in
scripts/start.sh to append instead (use ">>" for "$APP_LOG") or add a pre-start
rotation/backup step that moves or archives the existing "$APP_LOG" before
running nohup with JAR_FILE so historical logs (crash traces) are preserved;
update the nohup line and/or add a short rotation block referencing APP_LOG and
JAR_FILE accordingly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이거만 확인해주시면 될것같아요!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jiyun921, 네, 해당 부분이 주요 포인트입니다! 👍

현재 > 리다이렉션을 사용하면 애플리케이션이 재시작될 때마다 application.log 파일이 덮어쓰기되어 이전 실행의 로그(특히 크래시 원인)가 사라집니다.

가장 간단한 수정은 >> (append 모드)로 변경하는 것입니다:

-nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE > "$APP_LOG" 2>&1 < /dev/null &
+nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE >> "$APP_LOG" 2>&1 < /dev/null &

혹은 로그가 너무 커지는 것이 우려된다면, 시작 전 로테이션 방식도 고려해보실 수 있습니다:

# jar 파일 실행 전 기존 로그 백업
if [ -f "$APP_LOG" ]; then
  mv "$APP_LOG" "$APP_LOG.$(date +%Y%m%d_%H%M%S)"
fi
nohup java -jar -Dspring.profiles.active=prod -Xms256m -Xmx256m $JAR_FILE > "$APP_LOG" 2>&1 < /dev/null &

운영 환경에서 장애 분석이 필요할 경우를 대비해 append 모드(>>) 변경을 권장드립니다! 🐇

@github-actions
Copy link
Copy Markdown

Unit Test Results

  84 files  ±0    84 suites  ±0   1m 42s ⏱️ +2s
597 tests ±0  590 ✔️ ±0  7 💤 ±0  0 ±0 
600 runs  ±0  593 ✔️ ±0  7 💤 ±0  0 ±0 

Results for commit 1bb5678. ± Comparison against base commit c55817f.

@rlagkswn00 rlagkswn00 self-assigned this Mar 28, 2026
@rlagkswn00 rlagkswn00 added the 🐛 Bug Something isn't working label Mar 28, 2026
@rlagkswn00 rlagkswn00 merged commit 736bf20 into develop Mar 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants