diff --git a/.github/workflows/dev-cd.yml b/.github/workflows/dev-cd.yml
new file mode 100644
index 0000000..721c687
--- /dev/null
+++ b/.github/workflows/dev-cd.yml
@@ -0,0 +1,119 @@
+# 워크플로우의 이름 지정
+name: DEV-GUNBBANG-SERVER CD
+
+# 해당 workflow가 언제 실행될 것인지에 대한 트리거를 지정
+on:
+ push:
+ branches: [ dev ] # main branch로 push 될 때 실행됩니다.
+
+env:
+ S3_BUCKET_NAME: gunbbang-bucket-release
+ ZIP_FILE_NAME: dev-gunbbang-server
+
+jobs:
+ build:
+ name: Code deployment
+ environment: dev
+ runs-on: ubuntu-latest
+
+ steps:
+
+ # 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
+ - name: checkout
+ uses: actions/checkout@v3
+
+ # 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+
+ # 3) 환경변수 파일 생성
+ - name: make application.properties 파일 생성
+ run: |
+ pwd
+ ## create application.yml in api module
+ ## mkdir ./api/src/main/resources
+ cd ./api/src/main/resources
+ touch ./application.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+
+
+ ## create application.yml in client module
+ mkdir ./client/client-feign/src/main/resources
+ cd ./client/client-feign/src/main/resources
+ touch ./application.yml
+ touch ./client.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+
+
+ ## create application.yml in storage module
+ mkdir ./storage/db-core/src/main/resources
+ cd ./storage/db-core/src/main/resources
+ touch ./application.yml
+ touch ./db-core.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+ pwd
+
+ # GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
+ echo "${{ secrets.DEV_API_APPLICATION_YML }}" >> ./api/src/main/resources/application.yml
+ echo "${{ secrets.DEV_DB_CORE_APPLICATION_YML }}" >> ./storage/db-core/src/main/resources/application.yml
+ echo "${{ secrets.DEV_DB_CORE }}" >> ./storage/db-core/src/main/resources/db-core.yml
+ echo "${{ secrets.DEV_CLIENT }}" >> ./client/client-feign/src/main/resources/client.yml
+ echo "${{ secrets.DEV_CLIENT_APPLICATION_YML }}" >> ./client/client-feign/src/main/resources/application.yml
+
+ shell: bash
+
+ # 이 워크플로우는 gradle build
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
+ run: ./gradlew build -x test
+
+ # 디렉토리 생성
+ - name: Make Directory
+ run: mkdir -p dev-deploy
+
+ # Jar 파일 복사
+ - name: Copy Jar
+ run: cp ./api/build/libs/*.jar ./dev-deploy
+
+ # appspec.yml 파일 복사
+ - name: Copy appspec.yml
+ run: cp appspec.yml ./dev-deploy
+
+ # script files 복사
+ - name: Copy script
+ run: cp ./scripts/dev-deploy.sh ./dev-deploy/deploy.sh
+
+ - name: Make zip file
+ run: zip -r ./$ZIP_FILE_NAME.zip ./dev-deploy
+ shell: bash
+
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
+ aws-region: ap-northeast-2
+
+ - name: Upload to S3
+ run: aws s3 cp --region ap-northeast-2 ./$ZIP_FILE_NAME.zip s3://$S3_BUCKET_NAME/
+
+ # Deploy
+ - name: Deploy
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
+ run:
+ aws deploy create-deployment
+ --application-name gunbbang-server-codedeploy
+ --deployment-group-name dev-gunbbang-server-codedeploy-group
+ --file-exists-behavior OVERWRITE
+ --s3-location bucket=gunbbang-bucket-release,bundleType=zip,key=$ZIP_FILE_NAME.zip
+ --region ap-northeast-2
diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml
new file mode 100644
index 0000000..8fd9229
--- /dev/null
+++ b/.github/workflows/dev-ci.yml
@@ -0,0 +1,85 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
+
+name: DEV-Gunbbang-Server CI
+
+on:
+ push:
+ branches: [ "dev" ]
+ pull_request:
+ branches: [ "dev" ]
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ environment: dev
+ runs-on: ubuntu-latest
+ steps:
+ # 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
+ - name: checkout
+ uses: actions/checkout@v3
+
+ # 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+
+ # 3) 환경변수 파일 생성
+ - name: make application.yml 파일 생성
+ run: |
+ pwd
+ ## create application.yml in api module
+ ## mkdir ./api/src/main/resources
+ cd ./api/src/main/resources
+ touch ./application.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+
+
+ ## create application.yml in client module
+ mkdir ./client/client-feign/src/main/resources
+ cd ./client/client-feign/src/main/resources
+ touch ./application.yml
+ touch ./client.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+
+
+ ## create application.yml in storage module
+ mkdir ./storage/db-core/src/main/resources
+ cd ./storage/db-core/src/main/resources
+ touch ./application.yml
+ touch ./db-core.yml
+ ls -al
+ cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
+
+
+ # GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
+ echo "${{ secrets.DEV_API_APPLICATION_YML }}" >> ./api/src/main/resources/application.yml
+ echo "${{ secrets.DEV_DB_CORE_APPLICATION_YML }}" >> ./storage/db-core/src/main/resources/application.yml
+ echo "${{ secrets.DEV_DB_CORE }}" >> ./storage/db-core/src/main/resources/db-core.yml
+ echo "${{ secrets.DEV_CLIENT }}" >> ./client/client-feign/src/main/resources/client.yml
+ echo "${{ secrets.DEV_CLIENT_APPLICATION_YML }}" >> ./client/client-feign/src/main/resources/application.yml
+
+ shell: bash
+
+ # 이 워크플로우는 gradle build
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
+ run: ./gradlew build -x test
diff --git a/.github/workflows/cd.yml b/.github/workflows/prod-cd.yml
similarity index 86%
rename from .github/workflows/cd.yml
rename to .github/workflows/prod-cd.yml
index d0387fa..48174c8 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/prod-cd.yml
@@ -1,13 +1,14 @@
# 워크플로우의 이름 지정
-name: GUNBBANG-SERVER CD
+name: PROD-GUNBBANG-SERVER CD
# 해당 workflow가 언제 실행될 것인지에 대한 트리거를 지정
on:
push:
- branches: [ dev ] # main branch로 push 될 때 실행됩니다.
+ branches: [ prod ] # main branch로 push 될 때 실행됩니다.
env:
S3_BUCKET_NAME: gunbbang-bucket-release
+ ZIP_FILE_NAME: prod-gunbbang-server
jobs:
build:
@@ -76,22 +77,22 @@ jobs:
# 디렉토리 생성
- name: Make Directory
- run: mkdir -p deploy
+ run: mkdir -p prod-deploy
# Jar 파일 복사
- name: Copy Jar
- run: cp ./api/build/libs/*.jar ./deploy
+ run: cp ./api/build/libs/*.jar ./prod-deploy
# appspec.yml 파일 복사
- name: Copy appspec.yml
- run: cp appspec.yml ./deploy
+ run: cp appspec.yml ./prod-deploy
# script files 복사
- name: Copy script
- run: cp ./scripts/*.sh ./deploy
+ run: cp ./scripts/prod-deploy.sh ./prod-deploy/deploy.sh
- name: Make zip file
- run: zip -r ./gunbbang_server.zip ./deploy
+ run: zip -r ./$ZIP_FILE_NAME.zip ./prod-deploy
shell: bash
- name: Configure AWS credentials
@@ -102,7 +103,7 @@ jobs:
aws-region: ap-northeast-2
- name: Upload to S3
- run: aws s3 cp --region ap-northeast-2 ./gunbbang_server.zip s3://$S3_BUCKET_NAME/
+ run: aws s3 cp --region ap-northeast-2 ./$ZIP_FILE_NAME.zip s3://$S3_BUCKET_NAME/
# Deploy
- name: Deploy
@@ -112,7 +113,7 @@ jobs:
run:
aws deploy create-deployment
--application-name gunbbang-server-codedeploy
- --deployment-group-name gunbbang-server-codedeploy-group
+ --deployment-group-name prod-gunbbang-server-codedeploy-group
--file-exists-behavior OVERWRITE
- --s3-location bucket=gunbbang-bucket-release,bundleType=zip,key=gunbbang_server.zip
+ --s3-location bucket=gunbbang-bucket-release,bundleType=zip,key=$ZIP_FILE_NAME.zip
--region ap-northeast-2
diff --git a/.github/workflows/gradle.yml b/.github/workflows/prod-ci.yml
similarity index 97%
rename from .github/workflows/gradle.yml
rename to .github/workflows/prod-ci.yml
index e959a4a..88cb02e 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/prod-ci.yml
@@ -11,13 +11,13 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
-name: Gunbbang-Server CI
+name: PROD-Gunbbang-Server CI
on:
push:
- branches: [ "dev" ]
+ branches: [ "prod" ]
pull_request:
- branches: [ "dev" ]
+ branches: [ "prod" ]
permissions:
contents: read
diff --git a/api/src/main/resources/logback-spring.xml b/api/src/main/resources/logback-spring.xml
index 0d32c96..5924228 100644
--- a/api/src/main/resources/logback-spring.xml
+++ b/api/src/main/resources/logback-spring.xml
@@ -7,64 +7,110 @@
-
-
+
+
+
+
-
-
+
+
INFO
ACCEPT
DENY
- ${LOG_PATH}/${LOG_FILE_NAME}.log
+ ${LOG_PATH}/${DEV_LOG_FILE}.log
+
+ %msg%n
+
+
+
+ ${LOG_PATH}/${DEV_LOG_FILE}.%d{yyyy-MM-dd}.gz
+ 5
+ 1GB
+
+
+
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+ ${LOG_PATH}/${DEV_ERR_LOG_FILE}.log
+
+ %msg%n
+
+
+
+ ${LOG_PATH}/${DEV_ERR_LOG_FILE}.%d{yyyy-MM-dd}.gz
+ 5
+ 1GB
+
+
+
+
+
+ INFO
+ ACCEPT
+ DENY
+
+ ${LOG_PATH}/${PROD_LOG_FILE}.log
%msg%n
- ${LOG_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.gz
+ ${LOG_PATH}/${PROD_LOG_FILE}.%d{yyyy-MM-dd}.gz
14
1GB
-
-
+
+
ERROR
ACCEPT
DENY
- ${LOG_PATH}/${ERR_LOG_FILE_NAME}.log
+ ${LOG_PATH}/${PROD_ERR_LOG_FILE}.log
%msg%n
- ${LOG_PATH}/${ERR_LOG_FILE_NAME}.%d{yyyy-MM-dd}.gz
+ ${LOG_PATH}/${PROD_ERR_LOG_FILE}.%d{yyyy-MM-dd}.gz
14
1GB
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -73,6 +119,7 @@
-
+
+
diff --git a/scripts/dev-deploy.sh b/scripts/dev-deploy.sh
new file mode 100644
index 0000000..4dc2dc1
--- /dev/null
+++ b/scripts/dev-deploy.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+BUILD_PATH=$(ls /home/ubuntu/app/api-0.0.1-SNAPSHOT.jar)
+JAR_NAME=$(basename $BUILD_PATH)
+echo "> build 파일명: $JAR_NAME"
+
+echo "> build 파일 복사"
+DEPLOY_PATH=/home/ubuntu/app/nonstop/jar/
+cp $BUILD_PATH $DEPLOY_PATH
+
+PROFILE=dev
+echo "> PROFILE = $PROFILE 로 설정"
+
+echo "> application.jar 교체"
+RUNNING_APPLICATION=$PROFILE-GunbbangServer.jar # ??? 그냥 이름 임의로 지정해놓는듯
+RUNNING_APPLICATION_PATH=$DEPLOY_PATH$RUNNING_APPLICATION
+
+ln -Tfs $DEPLOY_PATH$JAR_NAME $RUNNING_APPLICATION_PATH
+
+echo "> 현재 구동중인 애플리케이션 pid 확인"
+RUNNING_PID=$(pgrep -f $RUNNING_APPLICATION)
+
+if [ -z $RUNNING_PID ]
+then
+ echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다."
+else
+ echo "> kill -15 $RUNNING_PID"
+ kill -15 $RUNNING_PID
+ exit=$?
+ sleep 10
+ if [ $exit -eq 0 ]; then
+ echo "kill -15 명령어로 서버가 다운되었습니다. exit status $exit. kill -15로 종료된 시각: $(date) "
+ else
+ echo "kill -15 명령어로 서버가 다운되지 않았습니다. exit status $exit."
+ echo "kill -9 명령어로 서버를 다운시킵니다. kill -9로 종료 시작한 시각: $(date)"
+ kill -9 $RUNNING_PID
+ sleep 20
+ fi
+fi
+
+current_datetime=$(date "+%Y년 %m월 %d일 %H시 %M분 %S초")
+echo "> $PROFILE 배포. 현재 시각: $current_datetime"
+nohup java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=$PROFILE $RUNNING_APPLICATION_PATH >> /home/ubuntu/app/nohup/nohup_$(date +\%Y_\%m_\%d_\%H_\%M_\%S).out 2>&1 &
diff --git a/scripts/deploy.sh b/scripts/prod-deploy.sh
similarity index 98%
rename from scripts/deploy.sh
rename to scripts/prod-deploy.sh
index 98a3c37..4965a22 100644
--- a/scripts/deploy.sh
+++ b/scripts/prod-deploy.sh
@@ -43,15 +43,15 @@ else
echo "> kill -15 $IDLE_PID"
kill -15 $IDLE_PID
exit=$?
- sleep 60
- if [ exit -eq 0 ]; then
+ sleep 15
+ if [ $exit -eq 0 ]; then
echo "kill -15 명령어로 서버가 다운되었습니다. exit status $exit. kill -15로 종료된 시각: $(date) "
else
echo "kill -15 명령어로 서버가 다운되지 않았습니다. exit status $exit."
echo "kill -9 명령어로 서버를 다운시킵니다. kill -9로 종료 시작한 시각: $(date)"
kill -9 $IDLE_PID
fi
- sleep 30
+ sleep 25
fi
echo "> $IDLE_PROFILE 배포"