-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chore] add scripts dir & modify build.gradle
add scripts dir add deploy.sh add start.sh add stop.sh modify build.gradle
- Loading branch information
1 parent
fecedad
commit 961ae8d
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,7 @@ dependencies { | |
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
REPOSITORY=/home/ubuntu/app | ||
cd $REPOSITORY | ||
|
||
# 1) 애플리케이션이 구동중인지 확인하기 위한 애플리케이션 이름, jar 파일의 이름 | ||
APP_NAME=RecordOfMemory | ||
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1) # `이 아닌 ' 사용해야함... | ||
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME | ||
|
||
# 2) 현재 인스턴스에서 애플리케이션이 구동중인지 확인, 구동중이면 종료 | ||
CURRENT_PID=$(pgrep -f $APP_NAME) | ||
|
||
if [ -z $CURRENT_PID ] | ||
then | ||
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." | ||
else | ||
echo "> kill -15 $CURRENT_PID" | ||
sudo kill -15 $CURRENT_PID | ||
sleep 5 | ||
fi | ||
|
||
# 3) app 디렉토리 권한 수정 | ||
cd /home/ubuntu | ||
sudo chmod 775 app | ||
sudo chown ubuntu app | ||
|
||
# 4) jar 파일을 배포 | ||
echo "> $JAR_PATH 배포" | ||
# nohup java -jar $JAR_PATH & | ||
nohup java -jar $JAR_PATH > /dev/null 2>&1 & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROJECT_ROOT="/home/ubuntu/app" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
APP_LOG="$PROJECT_ROOT/application.log" | ||
ERROR_LOG="$PROJECT_ROOT/error.log" | ||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
TIME_NOW=$(date +%c) | ||
|
||
# build 파일 복사 | ||
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG | ||
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE | ||
|
||
# jar 파일 실행 | ||
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG | ||
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & | ||
|
||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROJECT_ROOT="/home/ubuntu/app" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
TIME_NOW=$(date +%c) | ||
|
||
# 현재 구동 중인 애플리케이션 pid 확인 | ||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
|
||
# 프로세스가 켜져 있으면 종료 | ||
if [ -z $CURRENT_PID ]; then | ||
echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG | ||
else | ||
echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG | ||
kill -15 $CURRENT_PID | ||
fi |