Skip to content

Commit

Permalink
chore: 프로세스 종료 실패 시, 배포 종료 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pushedrumex committed Aug 13, 2024
1 parent 65ae52c commit 1e67a5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 1e67a5e

Please sign in to comment.