diff --git a/scripts/switch.sh b/scripts/switch.sh new file mode 100644 index 00000000..460d5a6e --- /dev/null +++ b/scripts/switch.sh @@ -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