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 812568b commit 8a8a218
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions server/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ x-app: &app
TZ: Asia/Seoul
SPRING_PROFILES_ACTIVE: prod
restart: always
depens_on:
- redis

services:
redis:
Expand Down
18 changes: 16 additions & 2 deletions server/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
NGINX_CONFIG_PATH="/etc/nginx/sites-available/api.fluffy.run"
HEALTH_CHECK_ATTEMPTS=5
HEALTH_CHECK_DELAY=3
BLUE_CONTAINTER_PORT=8080
GREEN_CONTAINTER_PORT=8081
BLUE_HEALTH_CHECK_URL="http://localhost:8082/actuator/health"
GREEN_HEALTH_CHECK_URL="http://localhost:8083/actuator/health"

Expand All @@ -13,6 +15,18 @@ health_check() {
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 "b"
curl http://localhost:8083/actuator/health

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

echo "d"
curl http://app-green:808/actuator/health

if [ "$response" -eq 200 ]; then
echo "Health check passed for $target_url"
return 0
Expand Down Expand Up @@ -55,8 +69,8 @@ IS_GREEN=$(docker container ps | grep app-green)

if [ -z "$IS_GREEN" ]; then
echo "### BLUE >> GREEN ###"
switch_container "app-blue" "app-green" "8081" "$GREEN_HEALTH_CHECK_URL"
switch_container "app-blue" "app-green" "$GREEN_CONTAINTER_PORT" "$GREEN_HEALTH_CHECK_URL"
else
echo "### GREEN >> BLUE ###"
switch_container "app-green" "app-blue" "8080" "$BLUE_HEALTH_CHECK_URL"
switch_container "app-green" "app-blue" "$BLUE_CONTAINTER_PORT" "$BLUE_HEALTH_CHECK_URL"
fi

0 comments on commit 8a8a218

Please sign in to comment.