Skip to content

Commit

Permalink
Create switch.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho authored Apr 16, 2024
1 parent 48845a2 commit d383ac5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/switch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
echo "> 현재 구동중인 Port 확인"

PROFILE_BLUE=$(curl -s http://localhost:8081/api/profile)
PROFILE_GREEN=$(curl -s http://localhost:8082/api/profile)

# blue가 사용중이면 green이 쉬고 있고, 반대면 blue가 쉬고 있음
if [ $PROFILE_BLUE == blue ]
then
IDLE_PORT=8082
elif [ $PROFILE_GREEN == green ]
then
IDLE_PORT=8081
else
echo "> 일치하는 Profile이 없습니다. Profile: $PROFILE_BLUE $PROFILE_GREEN"
echo "> 8081을 할당합니다."
IDLE_PORT=8081
fi

echo "> 전환할 Port: $IDLE_PORT"
echo "> Port 전환"
echo "set \$service_url http://localhost:${IDLE_PORT};" |sudo tee /etc/nginx/conf.d/service-url.inc

echo "> Nginx Reload"
sudo service nginx reload

0 comments on commit d383ac5

Please sign in to comment.