Skip to content

[FIX] 포트에 여러 프로세스가 물린 경우 배포 스크립트 종료 실패 수정 - #271

Merged
coli-geonwoo merged 1 commit into
developfrom
fix/deploy-kill-multiple-pids
Sep 25, 2026
Merged

coli-geonwoo merged 1 commit into
developfrom
fix/deploy-kill-multiple-pids

Conversation

@coli-geonwoo

@coli-geonwoo coli-geonwoo commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

배경

dev CD 실패 (run 36146349024).

배포 자체는 정상 완료됐고(health check 200, nginx 8080 전환 완료), 마지막 구버전 정리 단계에서만 실패했습니다.

Sending graceful shutdown signal to process 20188
20392 on port 8081
kill: failed to parse argument: '20188
20392'

원인

kill_process_on_port()에서 lsof -t -i:$port는 해당 포트를 점유한 PID를 줄바꿈으로 구분해 반환합니다. 8081 포트에 프로세스가 2개 물려 있어 $pid가 다중 값이 됐고, 따옴표로 묶인 "$pid"를 kill이 단일 인자로 받아 파싱에 실패했습니다. set -e 때문에 스크립트가 exit 1로 종료되면서 CD가 실패로 표시됐습니다.

graceful shutdown이나 WebSocket 연결 유지와는 무관한 스크립트 버그입니다.

변경 사항

  • kill_process_on_port()에서 PID 목록을 xargs로 전달해 각 프로세스에 개별적으로 kill -15 / kill -9를 보내도록 수정
  • 변수명 pid → pids로 변경하고 로그에 PID 목록을 공백 구분으로 출력
  • dev / prod 스크립트 모두 동일한 코드라 양쪽 다 적용

참고

포트에 PID가 2개 잡힌 원인 자체는 별도 확인이 필요합니다. 이전 배포에서 프로세스가 완전히 정리되지 않고 남았을 가능성이 있어, dev 서버에서 sudo lsof -i:8081로 확인이 필요합니다. 이 PR은 그 상황에서도 스크립트가 실패하지 않도록 하는 수정입니다.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 개선 사항
    • 개발 및 프로덕션 배포 중 지정된 포트를 사용하는 모든 프로세스를 종료하도록 개선했습니다.
    • 포트를 사용하는 프로세스가 없으면 성공적으로 종료하며, 종료되지 않은 프로세스에는 대기 후 강제 종료를 시도합니다.

lsof -t가 PID를 여러 개 반환하면 kill -15 "$pid"가 줄바꿈이 포함된
단일 인자를 받아 파싱에 실패했고, set -e로 인해 배포가 실패했다.
PID 목록을 xargs로 전달해 각 프로세스에 개별 시그널을 보내도록 수정한다.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: debate-timer/debate-timer-be/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 70e533b8-286b-4858-bda2-02a9c1c608bd

📥 Commits

Reviewing files that changed from the base of the PR and between 28aabf1 and 50178b9.

📒 Files selected for processing (2)
  • scripts/dev/zero-downtime-deploy.sh
  • scripts/prod/zero-downtime-deploy.sh
 ____________________________________________________________________________________________________________________________
< There is nothing quite so useless as doing with great efficiency something that should not be done at all. - Peter Drucker >
 ----------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@github-actions

Copy link
Copy Markdown

Test Results

169 files  169 suites   50s ⏱️
433 tests 433 ✅ 0 💤 0 ❌
445 runs  445 ✅ 0 💤 0 ❌

Results for commit 50178b9.

@github-actions

Copy link
Copy Markdown

📝 Test Coverage Report

Overall Project 91.64% 🍏

There is no coverage information present for the Files changed

@coli-geonwoo
coli-geonwoo merged commit d5a64cb into develop Sep 25, 2026
3 of 5 checks passed
@coli-geonwoo
coli-geonwoo deleted the fix/deploy-kill-multiple-pids branch September 25, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant