Skip to content

Commit

Permalink
[Feat] create deploy.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
hweyoung authored Dec 9, 2023
1 parent 60735ef commit 11b301a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

REPOSITORY=/home/ec2-user/app

cd $REPOSITORY

CURRENT_PID=$(pgrep -fla java | grep common | awk '{print $1}')

echo "현재 구동중인 애플리케이션 pid : $CURRENT_PID"

if [ -z $CURRENT_PID ]
then
echo "> Nothing to end."
else
echo "> kill -9 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

echo "> 새 애플리케이션 배포"

JAR_NAME=$(ls $REPOSITORY/ | grep '*.jar' | tail -n 1)
echo "Jar Name : $JAR_NAME"

echo "$JAR_NAME 에 실행권한 추가"
chmod +x $JAR_NAME


JAR_PATH=$REPOSITORY/$JAR_NAME
echo "Jar Path : $JAR_PATH"

echo "> $JAR_PATH deploy"
nohup java -jar \
-Duser.timezone=Asia/Seoul \
-Dspring.profiles.active=prod \
$JAR_NAME >> $REPOSITORY/logs/log_$(date +\%Y\%m\%d).log 2>&1 &

0 comments on commit 11b301a

Please sign in to comment.