Skip to content

Commit

Permalink
Merge pull request #4 from Minju-Kimm/main
Browse files Browse the repository at this point in the history
ci/cd setting
  • Loading branch information
Minju-Kimm authored Aug 22, 2024
2 parents b78e3ef + 13722a0 commit b61fa00
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
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
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ java {
}
}

jar {
enabled = false
}
configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down
1 change: 1 addition & 0 deletions nohup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error: Unable to access jarfile demo-0.0.1-SNAPSHOT.jar
22 changes: 22 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# scripts/start.sh
#!/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
20 changes: 20 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# scripts/stop.sh
#!/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
3 changes: 2 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ spring:
password: 'Alswn1858!'
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
url: jdbc:mysql://127.0.0.1:3306/toilet_db
url: jdbc:mysql://my-rds-instance.c7ooggw06nqt.ap-northeast-2.rds.amazonaws.com
:3306/my_rds_name

0 comments on commit b61fa00

Please sign in to comment.