스프링 부트와 AWS로 혼자 구현하는 웹 서비스 Chapter9 배포 자동화 구성을 위한 deploy.sh 추가 및 .travis.yml, appspec.yml 수정

This commit is contained in:
DESKTOP-FSO9NHB\User
2020-12-04 15:42:29 +09:00
parent aba017dc51
commit 3653b8537a
3 changed files with 60 additions and 7 deletions

View File

@@ -0,0 +1,37 @@
#!/bin/bash
REPOSITORY=/home/ec2-user/app/step2
PROJECT_NAME=springboot2-webservice
echo "> Build 파일 복사"
cp $REPOSITORY/zip/*.jar $REPOSITORY/
echo "> 현재 구동 중인 애플리케이션 pid 확인"
CURRENT_PID=$(pgrep -fl springboot2-webservice | grep jar | awk '{print $1}')
echo "현재 구동 중인 애플리케이션 pid : $CURRENT_PID"
if [ -z "$CURRENT_PID"]; then
echo "> 현재 구동 중인 애플리케이션이 없으므로 종료하지 않습니다."
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi
echo "> 새 애플리케이션 배포"
JAR_NAME=$(ls -tr $REPOSITORY/*.jar | tall -n 1)
echo "> JAR_NAME 에 실행권한 추가"
chmod +x $JAR_NAME
echo "> $JAR_NAME 실행"
nohup java -jar \
-Dspring.config.location=classpath:/application.properties,classpath:/application-real.properties,/home/ec2-user/app/application-oauth.properties,/home/ec2-user/app/application-real-db.properties \
-Dspring.profiles.active=real \
$JAR_NAME > $REPOSITORY/nohup.out 2>&1 &