feat: EwoooC 初始化 — 完整專案推版至 Gitea
Some checks failed
CD Pipeline / deploy (push) Failing after 59s

- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ogt
2026-04-19 01:21:13 +08:00
commit 1b4f3a7bbe
504 changed files with 387725 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
#!/bin/bash
# 健康檢查 API - 由 Nginx fcgiwrap 執行
# 用法: /api/health?service=<service_name>
# 設定 HTTP headers
echo "Content-Type: application/json"
echo "Access-Control-Allow-Origin: *"
echo "Access-Control-Allow-Methods: GET"
echo "Cache-Control: no-cache"
echo ""
# 解析查詢參數
SERVICE=$(echo "$QUERY_STRING" | sed -n 's/.*service=\([^&]*\).*/\1/p')
# 定義服務健康檢查 URL
declare -A HEALTH_URLS=(
["momo-uat"]="https://mo.wooo.work/health"
["momo-gcp"]="https://momo.wooo.work/health"
["gitlab"]="http://127.0.0.1:8929/"
["registry"]="http://127.0.0.1:5002/v2/"
["n8n"]="http://127.0.0.1:5678/"
["grafana"]="http://127.0.0.1:30030/"
["prometheus"]="http://10.43.25.78:9090/-/healthy"
["alertmanager"]="http://10.43.79.187:9093/-/healthy"
["superset"]="http://127.0.0.1:8088/health"
["metabase"]="http://127.0.0.1:3030/api/health"
)
# 檢查服務
if [[ -z "$SERVICE" ]]; then
# 返回所有服務狀態
echo '{"services": {'
first=true
for svc in "${!HEALTH_URLS[@]}"; do
url="${HEALTH_URLS[$svc]}"
start_time=$(date +%s%3N)
response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 --max-time 10 "$url" 2>/dev/null)
end_time=$(date +%s%3N)
response_time=$((end_time - start_time))
if [[ "$response" == "200" ]] || [[ "$response" == "302" ]] || [[ "$response" == "401" ]]; then
status="online"
else
status="offline"
fi
if [ "$first" = true ]; then
first=false
else
echo ","
fi
echo -n "\"$svc\": {\"status\": \"$status\", \"code\": $response, \"responseTime\": $response_time}"
done
echo '}}'
else
# 返回單個服務狀態
url="${HEALTH_URLS[$SERVICE]}"
if [[ -z "$url" ]]; then
echo '{"error": "Unknown service", "service": "'"$SERVICE"'"}'
exit 0
fi
start_time=$(date +%s%3N)
response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 --max-time 10 "$url" 2>/dev/null)
end_time=$(date +%s%3N)
response_time=$((end_time - start_time))
if [[ "$response" == "200" ]] || [[ "$response" == "302" ]] || [[ "$response" == "401" ]]; then
status="online"
else
status="offline"
fi
echo "{\"service\": \"$SERVICE\", \"status\": \"$status\", \"code\": $response, \"responseTime\": $response_time}"
fi

View File

@@ -0,0 +1,58 @@
#!/bin/bash
# 健康檢查 API
# 輸出 JSON 格式的服務狀態
echo "Content-Type: application/json"
echo "Access-Control-Allow-Origin: *"
echo "Cache-Control: no-cache, no-store, must-revalidate"
echo ""
check_service() {
local name=$1
local url=$2
local start_time=$(date +%s%N)
local response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 --max-time 5 "$url" 2>/dev/null)
local end_time=$(date +%s%N)
local response_time=$(( (end_time - start_time) / 1000000 ))
if [[ "$response" == "200" ]] || [[ "$response" == "302" ]] || [[ "$response" == "401" ]]; then
echo "\"$name\": {\"status\": \"online\", \"code\": $response, \"responseTime\": $response_time}"
else
echo "\"$name\": {\"status\": \"offline\", \"code\": $response, \"responseTime\": $response_time}"
fi
}
echo '{"services": {'
# 核心服務
check_service "momo-uat" "https://mo.wooo.work/health"
echo ","
check_service "momo-gcp" "https://momo.wooo.work/health"
echo ","
# 開發工具
check_service "gitlab" "http://127.0.0.1:8929/"
echo ","
check_service "registry" "http://127.0.0.1:5002/v2/"
echo ","
check_service "n8n" "http://127.0.0.1:5678/"
echo ","
# 監控服務
check_service "grafana" "http://127.0.0.1:30030/"
echo ","
check_service "prometheus" "http://10.43.25.78:9090/-/healthy"
echo ","
check_service "alertmanager" "http://10.43.79.187:9093/-/healthy"
echo ","
# BI 平台
check_service "superset" "http://127.0.0.1:8088/health"
echo ","
check_service "metabase" "http://127.0.0.1:3030/api/health"
echo '},'
echo "\"timestamp\": \"$(date -Iseconds)\""
echo '}'