-
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.
- Loading branch information
Showing
85 changed files
with
1,261 additions
and
766 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
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,52 @@ | ||
name: Run gradlew clean test when PR | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
PRTest: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: make application.yml | ||
run: | | ||
mkdir -p ./src/main/resources | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
touch ./application-common.yml | ||
touch ./application-prod.yml | ||
echo "${{ secrets.APPLICATION }}" > ./application.yml | ||
echo "${{ secrets.COMMON }}" > ./application-common.yml | ||
echo "${{ secrets.PROD }}" > ./application-prod.yml | ||
- name: make test application.yml | ||
run: | | ||
mkdir -p ./src/test/resources | ||
cd ./src/test/resources | ||
touch ./application.yml | ||
touch ./application-test.yml | ||
echo "${{ secrets.APPLICATION_TEST }}" > ./application.yml | ||
echo "${{ secrets.TEST }}" > ./application-test.yml | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build and Test | ||
run: ./gradlew clean test | ||
|
||
# Test 후 Report 생성 | ||
- name: Publish Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
junit_files: '**/build/test-results/test/TEST-*.xml' |
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 |
---|---|---|
@@ -1,17 +1,28 @@ | ||
version: 0.0 | ||
os: linux | ||
version: 0.0 # CodeDeploy Version. | ||
|
||
os: linux # 배포할 서버의 운영체제 | ||
|
||
files: | ||
- source: / | ||
destination: /home/ubuntu/app | ||
overwrite: yes | ||
- source: / # CodeDeploy에서 전달해 준 파일 중 destination으로 이동시킬 대상을 지정 (루트 경로 : 전체 파일) | ||
destination: /home/ubuntu/app # source에서 지정된 파일을 받을 위치 | ||
overwrite: yes # 기존 파일들을 덮어 쓰기 | ||
|
||
# CodeDeploy에서 EC2로 넘겨준 파일들을 모두 ec2-user 권한 부여. | ||
permissions: | ||
- object: / | ||
pattern: "**" | ||
owner: ubuntu | ||
group: ubuntu | ||
|
||
# CodeDeploy 배포 단계에서 실행할 명령어를 지정 (차례대로 스크립트들이 실행) | ||
hooks: | ||
ApplicationStart: | ||
- location: scripts/deploy.sh | ||
timeout: 60 | ||
- location: scripts/run_new_was.sh | ||
timeout: 180 | ||
runas: ubuntu | ||
- location: scripts/health.sh | ||
timeout: 180 | ||
runas: ubuntu | ||
- location: scripts/switch.sh | ||
timeout: 180 | ||
runas: ubuntu |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
##!/bin/bash | ||
|
||
BUILD_JAR=$(ls /home/ubuntu/app/build/libs/*.jar) | ||
JAR_NAME=$(basename $BUILD_JAR) | ||
|
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,43 @@ | ||
# health_check.sh | ||
|
||
#!/bin/bash | ||
|
||
# Crawl current connected port of WAS | ||
CURRENT_PORT=$(cat /home/ubuntu/service_url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
|
||
# Toggle port Number | ||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
exit 1 | ||
fi | ||
|
||
|
||
echo "> Start health check of WAS at http://localhost:${TARGET_PORT}/api/auth/health-check ..." | ||
|
||
for RETRY_COUNT in 1 2 3 4 5 6 7 8 9 10 | ||
do | ||
echo "> #${RETRY_COUNT} trying..." | ||
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${TARGET_PORT}/api/auth/health-check) | ||
|
||
if [ ${RESPONSE_CODE} -eq 200 ]; then | ||
echo "> New WAS successfully running" | ||
exit 0 | ||
elif [ ${RETRY_COUNT} -eq 10 ]; then | ||
echo "> Health check failed." | ||
exit 1 | ||
fi | ||
sleep 10 | ||
|
||
# if [ ${CURRENT_PORT} -eq ${TARGET_PORT} ]; then | ||
# echo "> Health Check Failed." | ||
# exit 1 | ||
# else | ||
# echo "> New WAS Successfully running." | ||
# exit 0 | ||
# fi | ||
done |
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,30 @@ | ||
# run_new_was.sh | ||
|
||
#!/bin/bash | ||
|
||
# 현재 포트 읽어오기 | ||
CURRENT_PORT=$(cat /home/ubuntu/service_url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
|
||
echo "> Current port of running WAS is ${CURRENT_PORT}." | ||
|
||
# 현재 포트가 8081이면 새로 WAS를 띄울 타겟 포트는 8082, 반대라면 8081 | ||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
fi | ||
|
||
TARGET_PID=$(lsof -Fp -i TCP:${TARGET_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') | ||
|
||
# 만약 타겟 포트에도 WAS가 떠있다면, kill하고 새롭게 WAS를 띄움 | ||
if [ ! -z ${TARGET_PID} ]; then | ||
echo "> Kill WAS running at ${TARGET_PORT}." | ||
sudo kill ${TARGET_PID} | ||
fi | ||
|
||
nohup java -jar -Dserver.port=${TARGET_PORT} /home/ubuntu/app/build/libs/* > /home/ubuntu/nohup.out 2>&1 & | ||
echo "> Now new WAS runs at ${TARGET_PORT}." | ||
exit 0 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
# switch.sh | ||
|
||
#!/bin/bash | ||
|
||
# Crawl current connected port of WAS | ||
CURRENT_PORT=$(cat /home/ubuntu/service_url.inc | grep -Po '[0-9]+' | tail -1) | ||
TARGET_PORT=0 | ||
|
||
echo "> Nginx currently proxies to ${CURRENT_PORT}." | ||
|
||
# Toggle port number | ||
if [ ${CURRENT_PORT} -eq 8081 ]; then | ||
TARGET_PORT=8082 | ||
elif [ ${CURRENT_PORT} -eq 8082 ]; then | ||
TARGET_PORT=8081 | ||
else | ||
echo "> No WAS is connected to nginx" | ||
exit 1 | ||
fi | ||
|
||
# Change proxying port into target port | ||
echo "set \$service_url http://127.0.0.1:${TARGET_PORT};" | tee /home/ubuntu/service_url.inc | ||
|
||
echo "> Now Nginx proxies to ${TARGET_PORT}." | ||
|
||
# Reload nginx | ||
sudo service nginx reload | ||
|
||
echo "> Nginx reloaded." |
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
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
Oops, something went wrong.