Skip to content

Commit 8c92b98

Browse files
committed
refactor: 헬스체크 로직 변경
1 parent da3ce19 commit 8c92b98

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI/CD Pipeline to EC2 with Blue/Green
22

33
on:
44
push:
5-
branches: [main, dev]
5+
branches: [main, dev, ci/env]
66

77
# ───────────────────────────────────────────────────────────────
88
concurrency:

deploy.sh

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,9 @@ $COMPOSE -f "$COMPOSE_FILE" rm -fs "$NEW_APP_SERVICE" || true
5656

5757
echo "컨테이너 기동…"
5858
# (compose v2.21+ 사용 시 주석 해제해 헬스체크 통합)
59-
# $COMPOSE -f "$COMPOSE_FILE" up -d --wait -t 180 "$NEW_APP_SERVICE"
60-
$COMPOSE -f "$COMPOSE_FILE" up -d "$NEW_APP_SERVICE"
59+
$COMPOSE -f "$COMPOSE_FILE" up -d --wait -t 180 "$NEW_APP_SERVICE"
6160

62-
############################ 3. 헬스체크 (curl 방식) ###########################
63-
echo "헬스체크 대기…"
64-
HEALTH_URL="http://localhost:${NEW_APP_PORT}/actuator/health"
65-
MAX=20; INTERVAL=10
66-
67-
for ((i=1;i<=MAX;i++)); do
68-
echo "--- 헬스 체크 시도 $i/$MAX ---"
69-
# curl의 전체 응답을 변수에 저장 (오류 시에도 스크립트가 중단되지 않도록)
70-
HEALTH_OUTPUT=$(curl -s "$HEALTH_URL" || echo "curl_failed")
71-
72-
# 전체 응답을 로그에 출력
73-
echo "응답: $HEALTH_OUTPUT"
74-
75-
# 응답 내용에 "status":"UP"이 포함되어 있는지 확인
76-
if echo "$HEALTH_OUTPUT" | grep -q '"status":"UP"'; then
77-
echo "✅ 헬스 통과 ($i/$MAX)"
78-
break
79-
fi
80-
81-
# 마지막 시도였다면 실패 처리
82-
[[ $i -eq $MAX ]] && { echo "🚨 헬스 실패"; exit 1; }
83-
84-
echo "⏳ 재시도 $i/$MAX"; sleep $INTERVAL
85-
done
86-
87-
############################ 4. Nginx 스위치 ##################################
61+
############################ 3. Nginx 스위치 ##################################
8862
sudo sed -E -i '/upstream current_app/,+1 s/127\.0\.0\.1:[0-9]+/127.0.0.1:'"$NEW_APP_PORT"'/' \
8963
"$NGINX_CONF"
9064
sudo nginx -t
@@ -98,7 +72,7 @@ DEPLOY_OK=true # ★ 여기서 성공 플래그 ON
9872

9973
echo "🎉 Blue/Green 전환 완료"
10074

101-
############################ 5. 모니터링 스택 재배포 ##########################
75+
############################ 4. 모니터링 스택 재배포 ##########################
10276
cd "$MONITORING_DIR"
10377

10478
echo "→ Rendering Alertmanager config with SLACK_WEBHOOK_URL"

0 commit comments

Comments
 (0)