Skip to content

Commit

Permalink
feat: blue green 무중단 배포 스크립트
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachneee committed Oct 15, 2024
1 parent 5f35ea9 commit 08f7122
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/backend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,31 @@ jobs:
-v log-volume:/app/logs \
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_BE_PROD }}
- name: Wait for Application Booting 30 seconds
run: |
sleep 30
- name: Health check the new container
run: |
echo "Performing health check for the new container on port $NEXT_PORT..."
HEALTH_STATUS=$(curl -s http://localhost:$NEXT_PORT/actuator/health | sed -n 's/.*"status":"\([^"]*\)".*/\1/p')
echo "Health check status: $HEALTH_STATUS"
if [ "$HEALTH_STATUS" != "UP" ]; then
echo "Health check failed. Rolling back..."
sudo docker rm -f haengdong-backend-$NEXT_PORT
exit 1
fi
echo "Health check passed."
MAX_ATTEMPTS=30
SLEEP_INTERVAL=2
ATTEMPT=1
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
HEALTH_STATUS=$(curl -s http://localhost:$NEXT_PORT/actuator/health | sed -n 's/.*"status":"\([^"]*\)".*/\1/p')

if [ "$HEALTH_STATUS" = "UP" ]; then
echo "Health check passed on attempt $ATTEMPT."
break
else
echo "Attempt $ATTEMPT: Health check status: $HEALTH_STATUS. Retrying in $SLEEP_INTERVAL seconds..."
ATTEMPT=$((ATTEMPT+1))
sleep $SLEEP_INTERVAL
fi

if [ $ATTEMPT -gt $MAX_ATTEMPTS ]; then
echo "Health check failed after $MAX_ATTEMPTS attempts. Rolling back..."
sudo docker rm -f haengdong-backend-$NEXT_PORT
exit 1
fi
done

- name: Update or create Nginx container to point to new container port
run: |
Expand Down

0 comments on commit 08f7122

Please sign in to comment.