Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
khoon9 committed Dec 17, 2023
2 parents a9643b3 + 2454964 commit 4430804
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/snow_server_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: snow server deploy
run-name: Running
on:
push:
branches:
- main

env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: snow-bucket-for-deploy
AWS_S3_BUCKET_DIR: snow-server-deploy
AWS_CODE_DEPLOY_APPLICATION: snow-application
AWS_CODE_DEPLOY_GROUP: snow-server-group

jobs:
build-with-gradle:
runs-on: ubuntu-20.04
steps:
- name: main 브랜치로 이동
uses: actions/checkout@v3
with:
ref: main
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "corretto"
- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew
- name: 프로젝트 빌드
run: ./gradlew clean build -x test
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_DEPLOY_AND_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEPLOY_AND_S3_SECRET_ACCESS_KEY }}
- name: S3에 업로드
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://$AWS_S3_BUCKET/$AWS_S3_BUCKET_DIR/$GITHUB_SHA.zip --source .
- name: EC2에 배포
run: aws deploy create-deployment
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }}
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }}
--s3-location bucket=$AWS_S3_BUCKET,key=$AWS_S3_BUCKET_DIR/$GITHUB_SHA.zip,bundleType=zip
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/snow-server
overwrite: yes

permissions:
- object: /home/ubuntu/snow-server
owner: ubuntu
group: ubuntu
mode: 755

hooks:
AfterInstall:
- location: scripts/stop.sh
timeout: 60
runas: root
ApplicationStart:
- location: scripts/start.sh
timeout: 60
runas: root
21 changes: 21 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

source /home/ubuntu/.profile

ROOT_PATH="/home/ubuntu/snow-server"
JAR="$ROOT_PATH/application.jar"

APP_LOG="$ROOT_PATH/application.log"
ERROR_LOG="$ROOT_PATH/error.log"
START_LOG="$ROOT_PATH/start.log"

NOW=$(date +%c)

echo "[$NOW] $JAR 복사" >> $START_LOG
cp $ROOT_PATH/build/libs/server-1.0.0.jar $JAR

echo "[$NOW] > $JAR 실행" >> $START_LOG
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG &

SERVICE_PID=$(pgrep -f $JAR)
echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG
14 changes: 14 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

ROOT_PATH="/home/ubuntu/snow-server"
JAR="$ROOT_PATH/application.jar"
STOP_LOG="$ROOT_PATH/stop.log"
SERVICE_PID=$(pgrep -f $JAR) # 실행중인 Spring 서버의 PID

if [ -z "$SERVICE_PID" ]; then
echo "서비스 NouFound" >> $STOP_LOG
else
echo "서비스 종료 " >> $STOP_LOG
kill "$SERVICE_PID"
# kill -9 $SERVICE_PID # 강제 종료를 하고 싶다면 이 명령어 사용
fi
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# log config
debug: false
logging:
level:
com.platform.match: debug
org.springframework.web.servlet: debug
org.hibernate.type.descriptor.sql.BasicBinder: trace
spring:
# db config
datasource:
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
# jpa config
jpa:
defer-datasource-initialization: true
# for dev
hibernate.ddl-auto: create
show-sql: true
properties:
hibernate.format_sql: true
hibernate.default_batch_fetch_size: 1000
# use data.sql file for dummy data
sql.init.mode: always

0 comments on commit 4430804

Please sign in to comment.