From d458006d2498c10e8df787bf99cfeff0cd0b989e Mon Sep 17 00:00:00 2001 From: kyy Date: Mon, 13 Oct 2025 10:11:50 +0900 Subject: [PATCH] =?UTF-8?q?OCR=20Health=20check=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{health_check.yml => api_health_check.yml} | 3 +- .gitea/workflows/ocr_health_check.yml | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) rename .gitea/workflows/{health_check.yml => api_health_check.yml} (98%) create mode 100644 .gitea/workflows/ocr_health_check.yml diff --git a/.gitea/workflows/health_check.yml b/.gitea/workflows/api_health_check.yml similarity index 98% rename from .gitea/workflows/health_check.yml rename to .gitea/workflows/api_health_check.yml index 6ae21e1..0bb2ec5 100644 --- a/.gitea/workflows/health_check.yml +++ b/.gitea/workflows/api_health_check.yml @@ -2,7 +2,7 @@ name: API Health Check on: schedule: - - cron: '* * * * *' + - cron: "* * * * *" jobs: health-check: @@ -32,4 +32,3 @@ jobs: curl -i -X POST -H 'Content-Type: application/json' -d '{"text": "## 🚨 API μƒνƒœ 확인 μ‹€νŒ¨\n**μ—”λ“œν¬μΈνŠΈ:** `http://172.16.10.176:8888/health/API`\n\nAPIκ°€ 5번의 μ‹œλ„μ— μ‘λ‹΅ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 확인이 ν•„μš”ν•©λ‹ˆλ‹€."}' ${{ secrets.MATTERMOST_WEBHOOK }} exit 1 fi - diff --git a/.gitea/workflows/ocr_health_check.yml b/.gitea/workflows/ocr_health_check.yml new file mode 100644 index 0000000..522df5c --- /dev/null +++ b/.gitea/workflows/ocr_health_check.yml @@ -0,0 +1,34 @@ +name: API Health Check + +on: + schedule: + - cron: "* * * * *" + +jobs: + health-check: + runs-on: ubuntu-latest + steps: + - name: Check API Health and Notify on Failure + run: | + success=false + for i in $(seq 1 5); do + response=$(curl -s -o /dev/null -w "%{http_code}" http://172.16.10.176:8890/health/API) + content=$(curl -s http://172.16.10.176:8890/health/API) + + if [ "$response" -eq 200 ] && echo "$content" | grep -q "ok"; then + echo "API is healthy (Attempt $i)." + success=true + break + else + echo "API health check failed (Attempt $i). HTTP Status: $response, Content: $content" + if [ $i -lt 5 ]; then + sleep 10 # Wait for 10 seconds before retrying + fi + fi + done + + if [ "$success" = "false" ]; then + echo "API health check failed after 5 attempts. Sending notification to Mattermost." + curl -i -X POST -H 'Content-Type: application/json' -d '{"text": "## 🚨 API μƒνƒœ 확인 μ‹€νŒ¨\n**μ—”λ“œν¬μΈνŠΈ:** `http://172.16.10.176:8890/health/API`\n\nAPIκ°€ 5번의 μ‹œλ„μ— μ‘λ‹΅ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 확인이 ν•„μš”ν•©λ‹ˆλ‹€."}' ${{ secrets.MATTERMOST_WEBHOOK }} + exit 1 + fi