Skip to content

Commit

Permalink
refactor: 배포 스크립트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Jan 8, 2025
1 parent 86a54b6 commit 6c75f50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion server/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ x-app: &app
TZ: Asia/Seoul
SPRING_PROFILES_ACTIVE: prod
restart: always
depens_on:
depends_on:
- redis

services:
Expand Down
36 changes: 24 additions & 12 deletions server/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,33 @@ BLUE_HEALTH_CHECK_URL="http://localhost:8082/actuator/health"
GREEN_HEALTH_CHECK_URL="http://localhost:8083/actuator/health"

health_check() {
local target_url=$1

for i in $(seq 1 $HEALTH_CHECK_ATTEMPTS); do
echo "Health check attempt ($i/$HEALTH_CHECK_ATTEMPTS) for $target_url"
response=$(curl -s -o /dev/null -w "%{http_code}" "$target_url")
echo "a"
curl http://localhost:8082/actuator/health

echo "a"
curl http://localhost:8082/actuator/health
echo "b"
curl http://localhost:8083/actuator/health

echo "b"
curl http://localhost:8083/actuator/health
echo "c"
curl http://app-blue:8082/actuator/health

echo "c"
curl http://app-blue:8082/actuator/health
echo "d"
curl http://app-green:8083/actuator/health

echo "d"
curl http://app-green:8083/actuator/health
echo "e"
curl http://127.0.0.1:8082/actuator/health

echo "f"
curl http://127.0.0.1:8083/actuator/health

echo "g"
curl http://localhost:8080/actuator/health

local target_url=$1

for i in $(seq 1 $HEALTH_CHECK_ATTEMPTS); do
echo "Health check attempt ($i/$HEALTH_CHECK_ATTEMPTS) for $target_url"
response=$(curl -s -o /dev/null -w "%{http_code}" "$target_url")

if [ "$response" -eq 200 ]; then
echo "Health check passed for $target_url"
Expand All @@ -48,6 +58,8 @@ switch_container() {
echo "Starting $next_container..."
docker compose -f compose.yml up "$next_container" -d

sleep 5

if ! health_check "$health_check_url"; then
echo "Health check failed, rolling back..."
docker compose -f compose.yml down "$next_container"
Expand Down

0 comments on commit 6c75f50

Please sign in to comment.