Skip to content

Commit

Permalink
[FEAT] 배포를 위한 스크림트, 설정 파일 작성
Browse files Browse the repository at this point in the history
- appspec.yml: 배포 환경변수 설정
- build.gradle: 빌드 시 plain 버전 생성 차단
- start.sh: 배포 실행 스크립트
- stop.sh: 배포 전 실행 중인 어플리케이션 중지 스크립트
  • Loading branch information
delphox60 committed Jul 16, 2023
1 parent 676720b commit 15611e9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/app
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop.sh
timeout: 60
runas: ubuntu
ApplicationStart:
- location: scripts/start.sh
timeout: 60
runas: ubuntu
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

jar {
enabled = false
}
19 changes: 19 additions & 0 deletions scripts/start.sh
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/application.jar"

APP_LOG="$PROJECT_ROOT/application.log"
ERROR_LOG="$PROJECT_ROOT/error.log"
DEPLOY_LOG="$PROJECT_ROOT/deploy.log"

TIME_NOW=$(date +%c)

echo "$TIME_NOW > $JAR_FILE file copied." >> $DEPLOY_LOG
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE

echo "$TIME_NOW > $JAR_FILE running application." >> $DEPLOY_LOG
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG &

CURRENT_PID=$(pgrep -f $JAR_FILE)
echo "$TIME_NOW > running process: $CURRENT_PID" >> $DEPLOY_LOG
17 changes: 17 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ubuntu/app"
JAR_FILE="$PROJECT_ROOT/application.jar"

DEPLOY_LOG="$PROJECT_ROOT/deploy.log"

TIME_NOW=$(date +%c)

CURRENT_PID=$(pgrep -f $JAR_FILE)

if [ -z $CURRENT_PID ]; then
echo "$TIME_NOW > There is no running applications now." >> $DEPLOY_LOG
else
kill -15 $CURRENT_PID
echo "$TIME_NOW > $CURRENT_PID: application terminated. " >> $DEPLOY_LOG
fi

0 comments on commit 15611e9

Please sign in to comment.