- .yml .properties 등 중요정보 파일은 .gitignore 필수
spring:
h2:
console:
enabled: true
path: /h2
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
username: sa
server:
address: localhost
port: 7946
- vim deploy.sh 로 파일 생성
#!/bin/bash
REPOSITORY=/home/ec2-user/app/spring-boot
PROJECT_NAME= git으로 받은 프로젝트명
cd $REPOSITORY/$PROJECT_NAME/
echo "> Git pull"
git pull
echo "> Project Build Start"
./gradlew build
echo "> Build File Copy"
cp $REPOSITORY/$PROJECT_NAME/build/libs/*.jar $REPOSITORY
echo "> 현재 구동중인 어플리케이션 pid 확인"
CURRENT_PID=$(pgrep -f ${PROJECT_NAME}.*.jar)
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/ | grep jar | tail -n 1)
echo "> JAR Name: $JAR_NAME"
nohup java -jar -Dspring.profiles.active=real $REPOSITORY/$JAR_NAME 2>&1 &