diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..8ecf1d3 --- /dev/null +++ b/scripts/deploy.sh @@ -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 &