Skip to content

Commit 6492c6b

Browse files
authored
chore(deploy): 배포 스크립트 deploy.sh 추가
1 parent ef143ae commit 6492c6b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

scripts/deploy.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
BUILD_JAR=$(ls /home/ec2-user/app/build/libs/*.jar)
4+
JAR_NAME=$(basename $BUILD_JAR)
5+
echo "> build 파일명: $JAR_NAME" >> /home/ec2-user/app/deploy.log
6+
7+
echo "> build 파일 복사" >> /home/ec2-user/app/deploy.log
8+
DEPLOY_PATH=/home/ec2-user/app/
9+
cp $BUILD_JAR $DEPLOY_PATH
10+
11+
echo "> 현재 실행중인 애플리케이션 pid 확인" >> /home/ec2-user/app/deploy.log
12+
CURRENT_PID=$(pgrep -f $JAR_NAME)
13+
14+
if [ -z "$CURRENT_PID" ]
15+
then
16+
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> /home/ec2-user/app/deploy.log
17+
else
18+
echo "> 현재 구동중인 애플리케이션 종료: $CURRENT_PID" >> /home/ec2-user/app/deploy.log
19+
kill -15 $CURRENT_PID
20+
sleep 5
21+
fi
22+
23+
DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME
24+
echo "> 애플리케이션 배포: $DEPLOY_JAR" >> /home/ec2-user/app/deploy.log
25+
nohup java -jar $DEPLOY_JAR >> /home/ec2-user/app/deploy.log 2>/home/ec2-user/app/deploy_err.log &

0 commit comments

Comments
 (0)