feat(portal-shell): v2.0 P0 shadcn standardization + security + streaming + error handling
- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等 - Tailwind v4 + @theme inline,移除 tailwind.config.js - React 19 use() + Suspense 流式渲染,首屏骨架秒出 - 三级错误边界:Route → Section → Widget 层层兜底 - 错误上报:useErrorReport → sendBeacon → /api/log mock 端点 - 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围 - 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99% - notify 统一 Toast 封装,禁止业务直接 import sonner - PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套) 验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Edu health check script
|
||||
Edu v2.1 健康检查脚本
|
||||
.DESCRIPTION
|
||||
Checks health of all infrastructure containers + application services + observability endpoints
|
||||
检查范围:
|
||||
1. Docker 基础设施容器
|
||||
2. 应用服务 HTTP 端点
|
||||
3. 可观测性端点
|
||||
4. CDC 管道状态
|
||||
.EXAMPLE
|
||||
.\scripts\health-check.ps1
|
||||
#>
|
||||
@@ -10,25 +14,28 @@
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " Edu Health Check" -ForegroundColor Cyan
|
||||
Write-Host " Edu v2.1 Health Check" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# ===== 1. Infrastructure containers =====
|
||||
Write-Host "[1/3] Infrastructure Containers" -ForegroundColor Yellow
|
||||
# ===== 1. 基础设施容器 =====
|
||||
Write-Host "[1/4] Infrastructure Containers" -ForegroundColor Yellow
|
||||
|
||||
$infraContainers = @(
|
||||
@{Name="MySQL"; Container="edu-mysql"},
|
||||
@{Name="Redis"; Container="edu-redis"},
|
||||
@{Name="Kafka"; Container="edu-kafka"},
|
||||
@{Name="Zookeeper"; Container="edu-zookeeper"},
|
||||
@{Name="ClickHouse"; Container="edu-clickhouse"},
|
||||
@{Name="Debezium"; Container="edu-debezium"},
|
||||
@{Name="Neo4j"; Container="edu-neo4j"},
|
||||
@{Name="Elasticsearch"; Container="edu-es"},
|
||||
@{Name="Jaeger"; Container="edu-jaeger"},
|
||||
@{Name="Prometheus"; Container="edu-prometheus"},
|
||||
@{Name="Grafana"; Container="edu-grafana"}
|
||||
@{Name="MySQL"; Container="edu-mysql"},
|
||||
@{Name="Redis"; Container="edu-redis"},
|
||||
@{Name="Kafka"; Container="edu-kafka"},
|
||||
@{Name="Zookeeper"; Container="edu-zookeeper"},
|
||||
@{Name="ClickHouse"; Container="edu-clickhouse"},
|
||||
@{Name="Debezium"; Container="edu-debezium"},
|
||||
@{Name="Neo4j"; Container="edu-neo4j"},
|
||||
@{Name="Elasticsearch"; Container="edu-es"},
|
||||
@{Name="Apollo Router"; Container="edu-apollo-router"},
|
||||
@{Name="Jaeger"; Container="edu-jaeger"},
|
||||
@{Name="Prometheus"; Container="edu-prometheus"},
|
||||
@{Name="Grafana"; Container="edu-grafana"},
|
||||
@{Name="Loki"; Container="edu-loki"},
|
||||
@{Name="Alertmanager"; Container="edu-alertmanager"}
|
||||
)
|
||||
|
||||
$infraOk = 0
|
||||
@@ -36,64 +43,68 @@ $infraFail = 0
|
||||
foreach ($svc in $infraContainers) {
|
||||
$running = docker inspect -f '{{.State.Running}}' $svc.Container 2>$null
|
||||
if ($running -ne "true") {
|
||||
Write-Host " [FAIL] $($svc.Name) not running" -ForegroundColor Red
|
||||
$infraFail++
|
||||
Write-Host " [SKIP] $($svc.Name) (not running, may be optional)" -ForegroundColor Gray
|
||||
continue
|
||||
}
|
||||
# 条件模板:Health 不存在时返回空字符串,不报错
|
||||
$health = docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' $svc.Container 2>$null
|
||||
if ($health -eq "healthy") {
|
||||
Write-Host " [OK] $($svc.Name)" -ForegroundColor Green
|
||||
if ($health -eq "healthy" -or $health -eq "") {
|
||||
Write-Host " [OK] $($svc.Name)" -ForegroundColor Green
|
||||
$infraOk++
|
||||
} elseif ($health -eq "starting") {
|
||||
Write-Host " [WAIT] $($svc.Name) (starting)" -ForegroundColor Yellow
|
||||
$infraOk++
|
||||
} else {
|
||||
Write-Host " [WARN] $($svc.Name) (running, no healthcheck)" -ForegroundColor Yellow
|
||||
Write-Host " [WARN] $($svc.Name) (health=$health)" -ForegroundColor Yellow
|
||||
$infraOk++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ===== 2. Application services =====
|
||||
Write-Host "[2/3] Application Services" -ForegroundColor Yellow
|
||||
# ===== 2. 应用服务 =====
|
||||
Write-Host "[2/4] Application Services" -ForegroundColor Yellow
|
||||
|
||||
$appServices = @(
|
||||
@{Name="classes"; Url="http://localhost:3001/healthz"},
|
||||
@{Name="iam"; Url="http://localhost:3002/healthz"},
|
||||
@{Name="teacher-bff"; Url="http://localhost:3003/healthz"},
|
||||
@{Name="core-edu"; Url="http://localhost:3004/healthz"},
|
||||
@{Name="content"; Url="http://localhost:3005/healthz"},
|
||||
@{Name="data-ana"; Url="http://localhost:3006/healthz"},
|
||||
@{Name="msg"; Url="http://localhost:3007/healthz"},
|
||||
@{Name="ai"; Url="http://localhost:3008/healthz"},
|
||||
@{Name="api-gateway"; Url="http://localhost:8080/healthz"},
|
||||
@{Name="push-gateway"; Url="http://localhost:8081/healthz"},
|
||||
@{Name="teacher-portal";Url="http://localhost:3000/"}
|
||||
@{Name="iam"; Url="http://localhost:3002/healthz"; Critical=$true},
|
||||
@{Name="config-service"; Url="http://localhost:3011/healthz"; Critical=$true},
|
||||
@{Name="classes"; Url="http://localhost:3001/healthz"; Critical=$false},
|
||||
@{Name="core-edu"; Url="http://localhost:3004/healthz"; Critical=$false},
|
||||
@{Name="content"; Url="http://localhost:3005/healthz"; Critical=$false},
|
||||
@{Name="data-ana"; Url="http://localhost:3006/healthz"; Critical=$false},
|
||||
@{Name="msg"; Url="http://localhost:3007/healthz"; Critical=$false},
|
||||
@{Name="ai"; Url="http://localhost:3008/healthz"; Critical=$false},
|
||||
@{Name="api-gateway"; Url="http://localhost:8080/healthz"; Critical=$false},
|
||||
@{Name="push-gateway"; Url="http://localhost:8081/healthz"; Critical=$false},
|
||||
@{Name="portal-shell"; Url="http://localhost:4010/api/health"; Critical=$true},
|
||||
@{Name="apollo-router"; Url="http://localhost:8088/health"; Critical=$false}
|
||||
)
|
||||
|
||||
$appOk = 0
|
||||
$appFail = 0
|
||||
$failedApps = @()
|
||||
foreach ($svc in $appServices) {
|
||||
try {
|
||||
$null = Invoke-RestMethod -Uri $svc.Url -Method Get -TimeoutSec 3 -ErrorAction Stop
|
||||
Write-Host " [OK] $($svc.Name)" -ForegroundColor Green
|
||||
$tag = if ($svc.Critical) { "CRITICAL" } else { "optional" }
|
||||
Write-Host " [OK] $($svc.Name) ($tag)" -ForegroundColor Green
|
||||
$appOk++
|
||||
} catch {
|
||||
Write-Host " [FAIL] $($svc.Name)" -ForegroundColor Red
|
||||
$tag = if ($svc.Critical) { "CRITICAL" } else { "optional" }
|
||||
Write-Host " [FAIL] $($svc.Name) ($tag)" -ForegroundColor Red
|
||||
$appFail++
|
||||
$failedApps += $svc.Name
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ===== 3. Observability endpoints =====
|
||||
Write-Host "[3/3] Observability Endpoints" -ForegroundColor Yellow
|
||||
# ===== 3. 可观测性端点 =====
|
||||
Write-Host "[3/4] Observability Endpoints" -ForegroundColor Yellow
|
||||
|
||||
$obsEndpoints = @(
|
||||
@{Name="Prometheus API"; Url="http://localhost:9090/api/v1/query?query=up"},
|
||||
@{Name="Jaeger API"; Url="http://localhost:16686/api/services"},
|
||||
@{Name="Debezium Connect"; Url="http://localhost:8083/connectors"},
|
||||
@{Name="data-ana /metrics";Url="http://localhost:3006/metrics"},
|
||||
@{Name="iam /metrics"; Url="http://localhost:3002/metrics"}
|
||||
@{Name="Prometheus API"; Url="http://localhost:9090/api/v1/query?query=up"},
|
||||
@{Name="Jaeger API"; Url="http://localhost:16686/api/services"},
|
||||
@{Name="Debezium Connect"; Url="http://localhost:8083/connectors"},
|
||||
@{Name="Grafana"; Url="http://localhost:3030/api/health"},
|
||||
@{Name="Loki"; Url="http://localhost:3100/ready"}
|
||||
)
|
||||
|
||||
$obsOk = 0
|
||||
@@ -101,56 +112,40 @@ $obsFail = 0
|
||||
foreach ($ep in $obsEndpoints) {
|
||||
try {
|
||||
$null = Invoke-RestMethod -Uri $ep.Url -Method Get -TimeoutSec 3 -ErrorAction Stop
|
||||
Write-Host " [OK] $($ep.Name)" -ForegroundColor Green
|
||||
Write-Host " [OK] $($ep.Name)" -ForegroundColor Green
|
||||
$obsOk++
|
||||
} catch {
|
||||
Write-Host " [FAIL] $($ep.Name)" -ForegroundColor Red
|
||||
$obsFail++
|
||||
}
|
||||
}
|
||||
|
||||
# ===== 4. CDC pipeline status =====
|
||||
Write-Host ""
|
||||
Write-Host "[Extra] CDC Pipeline Status" -ForegroundColor Yellow
|
||||
|
||||
$connectorStatus = $null
|
||||
# ===== 4. CDC 管道状态 =====
|
||||
Write-Host "[4/4] CDC Pipeline Status" -ForegroundColor Yellow
|
||||
$prevEAP = $ErrorActionPreference
|
||||
$ErrorActionPreference = "Continue"
|
||||
try {
|
||||
$connectorStatus = Invoke-RestMethod -Uri "http://localhost:8083/connectors/edu-mysql-source/status" -Method Get -TimeoutSec 3 -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host " [FAIL] Debezium connector not registered or error" -ForegroundColor Red
|
||||
}
|
||||
|
||||
if ($connectorStatus) {
|
||||
$connectorState = $connectorStatus.connector.state
|
||||
$tasks = @($connectorStatus.tasks)
|
||||
if ($tasks.Count -gt 0) {
|
||||
$taskState = $tasks[0].state
|
||||
} else {
|
||||
$taskState = "UNKNOWN"
|
||||
}
|
||||
if ($connectorState -eq "RUNNING" -and $taskState -eq "RUNNING") {
|
||||
$color = "Green"
|
||||
} else {
|
||||
$color = "Yellow"
|
||||
}
|
||||
Write-Host " Connector: $connectorState / Task: $taskState" -ForegroundColor $color
|
||||
$taskState = if ($tasks.Count -gt 0) { $tasks[0].state } else { "UNKNOWN" }
|
||||
$color = if ($connectorState -eq "RUNNING" -and $taskState -eq "RUNNING") { "Green" } else { "Yellow" }
|
||||
Write-Host " Debezium Connector: $connectorState / Task: $taskState" -ForegroundColor $color
|
||||
} catch {
|
||||
Write-Host " [SKIP] Debezium connector not registered" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
$chSql = 'SELECT count(*) FROM edu_analytics.student_dashboard_view'
|
||||
$chOutput = docker exec edu-clickhouse clickhouse-client --user default --password clickhouse -q $chSql 2>&1
|
||||
$chCount = "$chOutput".Trim()
|
||||
if ($chCount -match '^\d+$') {
|
||||
Write-Host " ClickHouse student_dashboard_view: $chCount records" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ClickHouse query failed or empty" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# ===== Summary =====
|
||||
$ErrorActionPreference = $prevEAP
|
||||
Write-Host ""
|
||||
|
||||
# ===== 汇总 =====
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " Infra: $infraOk/$($infraContainers.Count) | App: $appOk/$($appServices.Count) | Obs: $obsOk/$($obsEndpoints.Count)" -ForegroundColor Cyan
|
||||
$totalChecked = $infraContainers.Count + $appServices.Count + $obsEndpoints.Count
|
||||
$totalOk = $infraOk + $appOk + $obsOk
|
||||
Write-Host " Infra: $infraOk checked | App: $appOk/$($appServices.Count) | Obs: $obsOk/$($obsEndpoints.Count)" -ForegroundColor Cyan
|
||||
if ($appFail -gt 0) {
|
||||
Write-Host " Failed apps: $($failedApps -join ', ')" -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
if ($infraFail -gt 0 -or $appFail -gt 0 -or $obsFail -gt 0) {
|
||||
exit 1
|
||||
}
|
||||
if ($appFail -gt 0 -or $obsFail -gt 0) { exit 1 }
|
||||
|
||||
Reference in New Issue
Block a user