Skip to content

Commit f33f206

Browse files
committed
feat: 배포 스크립트 추가
1 parent ae6deb8 commit f33f206

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

scripts/start.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
ROOT_PATH="/home/ec2-user/Leets/LEETS"
4+
JAR="$ROOT_PATH/application.jar"
5+
6+
APP_LOG="$ROOT_PATH/application.log"
7+
ERROR_LOG="$ROOT_PATH/error.log"
8+
START_LOG="$ROOT_PATH/start.log"
9+
10+
NOW=$(date +%c)
11+
12+
echo "[$NOW] $JAR 복사" >> $START_LOG
13+
cp $ROOT_PATH/build/libs/leets-0.0.1-SNAPSHOT.jar $JAR
14+
15+
echo "[$NOW] > $JAR 실행" >> $START_LOG
16+
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG &
17+
18+
SERVICE_PID=$(pgrep -f $JAR)
19+
echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG

scripts/stop.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
ROOT_PATH="/home/ec2-user/Leets/LEETS"
4+
JAR="$ROOT_PATH/application.jar"
5+
STOP_LOG="$ROOT_PATH/stop.log"
6+
SERVICE_PID=$(pgrep -f $JAR) # 실행중인 Spring 서버의 PID
7+
8+
if [ -z "$SERVICE_PID" ]; then
9+
echo "서비스 NouFound" >> $STOP_LOG
10+
else
11+
echo "서비스 종료 " >> $STOP_LOG
12+
kill "$SERVICE_PID"
13+
# kill -9 $SERVICE_PID # 강제 종료를 하고 싶다면 이 명령어 사용
14+
fi

0 commit comments

Comments
 (0)