-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- run_new_was.sh 에서 변경된 포트가 service-url.inc에 반영이 안된 상태로 health_check.sh가 실행되는 문제 해결
- Loading branch information
1 parent
058422b
commit eedf3a5
Showing
4 changed files
with
32 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_PORT=$(cat /etc/nginx/conf.d/service-url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
# 현재 proxy 중인 실구동 port | ||
CURRENT_RUNNING_PORT=$(cat /etc/nginx/conf.d/service-url.inc | grep -Po '[0-9]+' | tail -1) | ||
|
||
echo "> Current port of running WAS is ${CURRENT_PORT}." | ||
echo "> Current port of running WAS is ${CURRENT_RUNNING_PORT}." | ||
|
||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
if [ ${CURRENT_RUNNING_PORT} -eq 8081 ]; then | ||
NEXT_RUNNING_PORT=8082 | ||
elif [ ${CURRENT_RUNNING_PORT} -eq 8082 ]; then | ||
NEXT_RUNNING_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
NEXT_RUNNING_PORT=8081 | ||
fi | ||
|
||
TARGET_PID=$(lsof -Fp -i TCP:${TARGET_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') | ||
# 혹시나 다른 프로세스가 실행되고 있을 경우를 대비하여 PID Kill | ||
CHECK_PID=$(lsof -Fp -i TCP:${NEXT_RUNNING_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') | ||
|
||
if [ ! -z ${TARGET_PID} ]; then | ||
echo "> Kill WAS running at ${TARGET_PORT}." | ||
sudo kill ${TARGET_PID} | ||
if [ ! -z ${CHECK_PID} ]; then | ||
echo "> Kill WAS running at ${NEXT_RUNNING_PORT}." | ||
sudo kill ${CHECK_PID} | ||
fi | ||
|
||
|
||
if [ "$DEPLOYMENT_GROUP_NAME" == "prod" ] | ||
then | ||
nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=prod /home/ubuntu/operation/operation-api/build/libs/operation-api-0.0.1-SNAPSHOT.jar > /dev/null 2> /dev/null < /dev/null & | ||
echo "> Now new WAS runs at ${TARGET_PORT}." | ||
nohup java -jar -Dserver.port=${NEXT_RUNNING_PORT} -Dspring.profiles.active=prod /home/ubuntu/operation/operation-api/build/libs/operation-api-0.0.1-SNAPSHOT.jar > /dev/null 2> /dev/null < /dev/null & | ||
echo "> Now new WAS runs at ${NEXT_RUNNING_PORT}." | ||
fi | ||
|
||
if [ "$DEPLOYMENT_GROUP_NAME" == "dev" ] | ||
then | ||
nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=dev /home/ubuntu/operation/operation-api/build/libs/operation-api-0.0.1-SNAPSHOT.jar > /dev/null 2> /dev/null < /dev/null & | ||
echo "> Now new WAS runs at ${TARGET_PORT}." | ||
nohup java -jar -Dserver.port=${NEXT_RUNNING_PORT} -Dspring.profiles.active=dev /home/ubuntu/operation/operation-api/build/libs/operation-api-0.0.1-SNAPSHOT.jar > /dev/null 2> /dev/null < /dev/null & | ||
echo "> Now new WAS runs at ${NEXT_RUNNING_PORT}." | ||
fi | ||
sleep 10 | ||
|
||
echo "set \$service_url http://127.0.0.1:${NEXT_RUNNING_PORT};" |sudo tee /etc/nginx/conf.d/service-url.inc | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,12 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_PORT=$(cat /etc/nginx/conf.d/service-url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
CURRENT_RUNNING_PORT=$(cat /etc/nginx/conf.d/service-url.inc | grep -Po '[0-9]+' | tail -1) | ||
|
||
echo "> Nginx currently proxies to ${CURRENT_PORT}." | ||
|
||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
exit 1 | ||
fi | ||
|
||
echo "set \$service_url http://127.0.0.1:${TARGET_PORT};" |sudo tee /etc/nginx/conf.d/service-url.inc | ||
|
||
echo "> Now Nginx proxies to ${TARGET_PORT}." | ||
echo "> Nginx currently proxies to ${CURRENT_RUNNING_PORT}." | ||
|
||
sudo service nginx reload | ||
|
||
echo "> Nginx reloaded." | ||
|
||
CURRENT_PID=$(lsof -Fp -i TCP:${CURRENT_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') | ||
|
||
sudo kill ${CURRENT_PID} | ||
echo "> curl -s http://127.0.0.1:$CURRENT_RUNNING_PORT/api/v1/test" | ||
echo "> Now Nginx proxies to ${CURRENT_RUNNING_PORT}." |