From d6a900577cb82552a3923b98d7ff1917bfab7d71 Mon Sep 17 00:00:00 2001 From: TRE <37261785+takoyakimchi@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:35:23 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20chore:=20prod=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EC=9D=98=20CD=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20?= =?UTF-8?q?=EB=AC=B4=EC=A4=91=EB=8B=A8=EB=B0=B0=ED=8F=AC=20=EA=B5=AC?= =?UTF-8?q?=EC=B6=95=20(#685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/backend-cd-workflow-prod.yml | 73 ++----------------- 1 file changed, 6 insertions(+), 67 deletions(-) diff --git a/.github/workflows/backend-cd-workflow-prod.yml b/.github/workflows/backend-cd-workflow-prod.yml index fb127b8d7..cc1b42457 100644 --- a/.github/workflows/backend-cd-workflow-prod.yml +++ b/.github/workflows/backend-cd-workflow-prod.yml @@ -43,55 +43,12 @@ jobs: run: | sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-friendogly - - name: Find Java Application PID And Kill PID - id: find_pid + - name: Deploy prod-a run: | - sudo pgrep -f friendogly-0.0.1-SNAPSHOT.jar | xargs sudo kill -9 | true - - - name: Check if WAS is running on port 8080 after stop - run: | - PID=$(lsof -t -i:8080 || true) - if [ -n "$PID" ]; then - echo "Server is still running with PID: $PID" - exit 1 - else - echo "Server successfully stopped." - fi - - - name: Start server - run: | - cd backend/build/libs - echo "File creation time(KR-09:00):" - ls -l --time=ctime friendogly-0.0.1-SNAPSHOT.jar - sudo nohup java -jar friendogly-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod --jwt.secret-key=${{ secrets.JWT_SECRET_KEY }} --jwt.access-expiration-time=${{ secrets.JWT_ACCESS_EXPIRATION_TIME }} --jwt.refresh-expiration-time=${{ secrets.JWT_REFRESH_EXPIRATION_TIME }} --kakao.admin-key=${{ secrets.KAKAO_ADMIN_KEY }} --spring.datasource.writer.hikari.jdbc-url=${{ secrets.MYSQL_RDS_WRITER_URL }} --spring.datasource.writer.hikari.username=${{ secrets.MYSQL_RDS_USERNAME }} --spring.datasource.writer.hikari.password=${{ secrets.MYSQL_RDS_PASSWORD }} --spring.datasource.reader.hikari.jdbc-url=${{ secrets.MYSQL_RDS_READER_URL }} --spring.datasource.reader.hikari.username=${{ secrets.MYSQL_RDS_USERNAME }} --spring.datasource.reader.hikari.password=${{ secrets.MYSQL_PASSWORD }} & - echo "start backend server" - - - name: Wait until WAS being started - run: | - URL="http://localhost:8080/healthchecktestapi" - wait_time=0 - - while true; do - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL" | true) - - if [[ $HTTP_STATUS =~ ^[0-9]+$ ]] && [ "$HTTP_STATUS" -eq 404 ]; then - echo "WAS has started" - break - fi - - if [ $wait_time -ge 120 ]; then - echo "WAS has not started, waited too long" - break - fi - - echo "WAS has not yet started" - - sleep 3 - wait_time=$((wait_time + 3)) - done + sudo chmod +x /home/ubuntu/deploy/deploy.sh + sudo /home/ubuntu/deploy/deploy.sh build-b: - needs: deploy-a runs-on: self-hosted-prod-b steps: @@ -127,25 +84,7 @@ jobs: run: | sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-friendogly - - name: Find Java Application PID And Kill PID - id: find_pid - run: | - sudo pgrep -f friendogly-0.0.1-SNAPSHOT.jar | xargs sudo kill -9 | true - - - name: Check if WAS is running on port 8080 after stop - run: | - PID=$(lsof -t -i:8080 || true) - if [ -n "$PID" ]; then - echo "Server is still running with PID: $PID" - exit 1 - else - echo "Server successfully stopped." - fi - - - name: Start server + - name: Deploy prod-b run: | - cd backend/build/libs - echo "File creation time(KR-09:00):" - ls -l --time=ctime friendogly-0.0.1-SNAPSHOT.jar - sudo nohup java -jar friendogly-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod --jwt.secret-key=${{ secrets.JWT_SECRET_KEY }} --jwt.access-expiration-time=${{ secrets.JWT_ACCESS_EXPIRATION_TIME }} --jwt.refresh-expiration-time=${{ secrets.JWT_REFRESH_EXPIRATION_TIME }} --kakao.admin-key=${{ secrets.KAKAO_ADMIN_KEY }} --spring.datasource.writer.hikari.jdbc-url=${{ secrets.MYSQL_RDS_WRITER_URL }} --spring.datasource.writer.hikari.username=${{ secrets.MYSQL_RDS_USERNAME }} --spring.datasource.writer.hikari.password=${{ secrets.MYSQL_RDS_PASSWORD }} --spring.datasource.reader.hikari.jdbc-url=${{ secrets.MYSQL_RDS_READER_URL }} --spring.datasource.reader.hikari.username=${{ secrets.MYSQL_RDS_USERNAME }} --spring.datasource.reader.hikari.password=${{ secrets.MYSQL_PASSWORD }} & - echo "start backend server" + sudo chmod +x /home/ubuntu/deploy/deploy.sh + sudo /home/ubuntu/deploy/deploy.sh