Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 프로세스 종료 실패 시, 배포 종료 로직 추가 #73

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ APP_LOG=$DEPLOY_PATH/application.log
ERROR_LOG=$DEPLOY_PATH/deploy-error.log
DEPLOY_LOG=$DEPLOY_PATH/deploy.log

echo "\n[ $(date +%c) ] 배포 시작" >> $DEPLOY_LOG
echo "[ $(date +%c) ] 배포 시작" >> $DEPLOY_LOG

echo "[ $(date +%c) ] Build 파일 복사" >> $DEPLOY_LOG
cp $PROJECT_ROOT/$PROJECT_NAME/build/libs/*.jar $DEPLOY_PATH/
Expand Down Expand Up @@ -43,12 +43,17 @@ else
sudo sh $SCRIPT_PATH/kill.sh $IDLE_PORT
fi

if [ $? -ne 0 ]; then
echo "[ $(date +%c) ] 새 어플리케이션을 배포하지 않고 종료" >> $DEPLOY_LOG
exit 1
fi

echo "[ $(date +%c) ] 새 어플리케이션 배포" >> $DEPLOY_LOG

JAR_NAME=$(ls -tr "$DEPLOY_PATH" | grep jar | tail -n 1)

echo "[ $(date +%c) ] JAR Name: $JAR_NAME" >> $DEPLOY_LOG
nohup java -jar $DEPLOY_PATH/"$JAR_NAME" --spring.profiles.active=$IDLE_PROFILE > $APP_LOG 2> $ERROR_LOG &
nohup java -jar $DEPLOY_PATH/"$JAR_NAME" --spring.profiles.active=$IDLE_PROFILE >> $APP_LOG 2>> $ERROR_LOG &

echo "[ $(date +%c) ] $IDLE_PROFILE 10초 후 Health check 시작" >> $DEPLOY_LOG
sleep 10
Expand Down
1 change: 0 additions & 1 deletion scripts/kill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ do
if [ $retry_count -eq 10 ]
then
echo "[ $(date +%c) ] $IDLE_PORT kill 실패." >> $DEPLOY_LOG
echo "[ $(date +%c) ] 새 어플리케이션을 배포하지 않고 종료" >> $DEPLOY_LOG
exit 1
fi

Expand Down
Loading