Skip to content

Commit

Permalink
Code Deploy Error Fix (#51)
Browse files Browse the repository at this point in the history
* fix CodeDeploy Error Msg Detail :
The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.

* fix Typo

* fix Unable to access jarfile /home/ubuntu/spring-github-action/application.jar 에러 수정

* fix Error: Unable to access jarfile /home/ubuntu/spring-github-action/home/ubuntu/spring-github-action/gamemoonchul-0.0.1-SNAPSHOT.jar Error Fix

* fix stop.log > Service Not Found Fix

* fix java.lang.IllegalStateException: Could not load store from 'classpath:keystore-aws.p12' Error Fix
  • Loading branch information
rookedsysc authored Mar 24, 2024
1 parent ef863fe commit 23872d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/cd-wordflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
cd ./src/main/resources
touch ./application.yaml
echo "${{ secrets.APPLICATION_YAML }}" > ./application.yaml
echo "${{ secrets.AWS_KEYSTORE }}" | base64 --decode > ./keystore-aws.p12
cd ../../test/resources
touch ./application.yaml
echo "${{ secrets.APPLICATION_TEST_YAML }}" > ./application.yaml
Expand All @@ -57,26 +58,13 @@ jobs:
cp ./appspec.yml ./deploy/
cp -r ./scripts ./deploy/
# 압축파일 형태로 전달
- name: Make zip file
run: zip -r ./springboot-intro-build.zip ./deploy

# CodeDeploy 파일 복사
- name: Copy CodeDeploy Files
run: |
cp ./appspec.yml ./deploy/
cp -r ./scripts ./deploy/
- name: Deliver to AWS S3
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ap-southeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: S3에 업로드
run: aws deploy push --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://gamemuncheol-s3/deploy --source ./deploy
run: aws deploy push --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://gamemuncheol-s3/deploy.zip --source ./deploy
- 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=cicdtest/$GITHUB_SHA.zip,bundleType=zip
run: aws deploy create-deployment --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --s3-location bucket=gamemuncheol-s3,key=deploy/springboot-intro-build.zip,bundleType=zip


run: aws deploy create-deployment --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --s3-location bucket=gamemuncheol-s3,key=deploy.zip,bundleType=zip
4 changes: 1 addition & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/bash

ROOT_PATH="/home/ubuntu/spring-github-action"
JAR="$ROOT_PATH/application.jar"
JAR="$ROOT_PATH/gamemoonchul-0.0.1-SNAPSHOT.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/spring-github-action-1.0.0.jar $JAR

echo "[$NOW] > $JAR 실행" >> $START_LOG
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG &
Expand Down
4 changes: 2 additions & 2 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

ROOT_PATH="/home/ubuntu/spring-github-action"
JAR="$ROOT_PATH/application.jar"
JAR="$ROOT_PATH/gamemoonchul-0.0.1-SNAPSHOT.jar"
STOP_LOG="$ROOT_PATH/stop.log"
SERVICE_PID=$(pgrep -f $JAR) # 실행중인 Spring 서버의 PID

if [ -z "$SERVICE_PID" ]; then
echo "서비스 NouFound" >> $STOP_LOG
echo "서비스 NotFound" >> $STOP_LOG
else
echo "서비스 종료 " >> $STOP_LOG
kill "$SERVICE_PID"
Expand Down

0 comments on commit 23872d3

Please sign in to comment.