diff --git a/.github/workflows/production-deploy.yml b/.github/workflows/production-deploy.yml index 671b6689..9cb358c3 100644 --- a/.github/workflows/production-deploy.yml +++ b/.github/workflows/production-deploy.yml @@ -68,9 +68,8 @@ jobs: envs: NLB_ID,ACCESS_TOKEN_SECRET_KEY,REFRESH_TOKEN_SECRET_KEY,DB_URL,DB_USERNAME,DB_PASSWORD script: | cd ~/snackgame-server/repo - git fetch origin main - git checkout -B main origin/main - git pull --ff-only origin main --no-recurse-submodules + git fetch origin main + git reset --hard origin/main chmod +x scripts/deploy-rolling.sh scripts/deploy-rolling.sh \ ${{ secrets.NLB_BACKEND_02_HTTP }} \ @@ -99,8 +98,7 @@ jobs: script: | cd ~/snackgame-server/repo git fetch origin main - git checkout -B main origin/main - git pull --ff-only origin main --no-recurse-submodules + git reset --hard origin/main chmod +x scripts/deploy-rolling.sh scripts/deploy-rolling.sh \ ${{ secrets.NLB_BACKEND_01_HTTP }} \ diff --git a/build.gradle.kts b/build.gradle.kts index 17853408..076a39eb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,6 +36,9 @@ dependencies { implementation("com.google.firebase:firebase-admin:9.2.0") implementation("com.squareup.okhttp3:okhttp:4.2.2") + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("io.micrometer:micrometer-registry-prometheus") + runtimeOnly("com.h2database:h2") runtimeOnly("com.mysql:mysql-connector-j") diff --git a/scripts/deploy-rolling.sh b/scripts/deploy-rolling.sh index 6e3776ac..15122c6d 100755 --- a/scripts/deploy-rolling.sh +++ b/scripts/deploy-rolling.sh @@ -36,20 +36,18 @@ set_drain() { --network-load-balancer-id "$NLB_ID" \ --backend-set-name snackgame-http \ --backend-name "$HTTP_BACKEND" \ - --is-drain "$is_drain" + --is-drain "$is_drain" \ + --wait-for-state SUCCEEDED \ + --max-wait-seconds 120 oci nlb backend update \ --auth instance_principal \ --network-load-balancer-id "$NLB_ID" \ --backend-set-name snackgame-https \ --backend-name "$HTTPS_BACKEND" \ - --is-drain "$is_drain" - - - if [ "$is_drain" = "true" ]; then - echo "[NLB] 드레인 적용 대기 중 (10초)..." - sleep 10 - fi + --is-drain "$is_drain" \ + --wait-for-state SUCCEEDED \ + --max-wait-seconds 120 } @@ -99,6 +97,9 @@ cd "$COMPOSE_DIR" set_drain true +echo "기존 연결 종료 대기..." +sleep 15 + echo "[Pull] 새 이미지 받는 중..." docker compose pull diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 142f81ad..27a440f6 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -20,3 +20,14 @@ server: session: cookie: same-site: none + +management: + endpoints: + web: + exposure: + include: "health,prometheus,loggers" + endpoint: + health: + show-details: never + prometheus: + enabled: true \ No newline at end of file diff --git a/src/main/resources/application-production.yml b/src/main/resources/application-production.yml index 8ae6c9bb..b381aefe 100644 --- a/src/main/resources/application-production.yml +++ b/src/main/resources/application-production.yml @@ -6,6 +6,11 @@ spring: jpa: hibernate: ddl-auto: validate + servlet: + session: + cookie: + same-site: none + security: jwt: token: @@ -13,14 +18,26 @@ security: access-expiry-days: ${ACCESS_TOKEN_EXPIRY_DAYS} refresh-secret-key: ${REFRESH_TOKEN_SECRET_KEY} refresh-expiry-days: ${REFRESH_TOKEN_EXPIRY_DAYS} + server: port: ${APPLICATION_PORT} forward-headers-strategy: native - servlet: - session: - cookie: - same-site: none springdoc: api-docs: enabled: false + +management: + endpoints: + web: + exposure: + include: "health,prometheus" + endpoint: + health: + show-details: never + prometheus: + enabled: true + metrics: + tags: + application: snackgame + environment: production \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9ab0ffb6..94d0b037 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,5 +26,13 @@ springdoc: disabled: true override-with-generic-response: false +management: + endpoints: + web: + exposure: + include: "" + endpoint: + health: + show-details: never server: shutdown: graceful