forked from GDSC-snowflowerthon/Kidari-team03-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
28 lines (24 loc) · 909 Bytes
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
BUILD_JAR=$(ls /home/ubuntu/build/*.jar)
JAR_NAME=$(basename $BUILD_JAR)
rm /home/ubuntu/deploy.log
echo "> build 파일명: $JAR_NAME" >> /home/ubuntu/deploy.log
echo "> build 파일 복사" >> /home/ubuntu/deploy.log
DEPLOY_PATH=/home/ubuntu/
cp $BUILD_JAR $DEPLOY_PATH
echo "> 현재 실행중인 애플리케이션 pid 확인" >> /home/ubuntu/deploy.log
CURRENT_PID=$(pgrep -f $JAR_NAME)
if [ -z $CURRENT_PID ]
then
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> /home/ubuntu/deploy.log
else
echo "> kill -15 $CURRENT_PID"
sudo kill -15 $CURRENT_PID
sleep 5
fi
DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME
echo "> DEPLOY_PATH: $DEPLOY_PATH"
echo "> JAR_NAME: $JAR_NAME"
echo "> DEPLOY_JAR: $DEPLOY_JAR"
echo "> DEPLOY_JAR 배포" >> /home/ubuntu/deploy.log
nohup java -jar $DEPLOY_JAR >> /home/ubuntu/deploy.log 2>/home/ubuntu/deploy_err.log &