---
name: infra-check
description: >
  当用户要求检查服务状态、验证基础设施健康、查看日志位置、
  或检查 Gitea Runner 状态时使用。
  触发短语：检查服务状态、健康检查、查日志、服务器状态、
  infra check、health check、Gitea Runner 状态。
---

# 基础设施检查技能

## 全栈健康检查

按以下顺序逐层检查：

```bash
# 1. 应用进程
pm2 status

# 2. Docker 容器
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'

# 3. API 健康
curl -s http://localhost:<backend_port>/api/v1/health | jq .

# 4. 前端可访问
curl -s -o /dev/null -w "HTTP %{http_code}" http://localhost:<frontend_port>

# 5. Nginx
systemctl status nginx
```

端口信息参考 `docs/ops/01-server-infrastructure.md`（生产 60xx，UAT 70xx，开发 30xx）。

## Gitea 服务检查

```bash
# Gitea 服务状态
sudo systemctl status gitea.service

# Actions Runner 状态
sudo systemctl status act-runner.service
sudo journalctl -u act-runner.service -n 50 --no-pager

# 分支保护规则
curl -s "http://localhost:3000/api/v1/repos/FFAIWorkspace/workspace/branch_protections" \
  -H "Authorization: token $GITEA_API_TOKEN" | jq .
```

Gitea 基础设施详情参考 `docs/ops/02-gitea-config.md`。

## 日志位置

| 日志类型 | 位置 |
|---------|------|
| 应用日志 | `pm2 logs` 或 `<project>/backend/logs/` |
| Nginx 访问日志 | `/var/log/nginx/access.log` |
| Nginx 错误日志 | `/var/log/nginx/error.log` |
| PostgreSQL | `docker logs <postgres_container>` |
| Redis | `docker logs <redis_container>` |
| Temporal | `docker logs <temporal_container>` |

## Health Check API 端点

| 端点 | 用途 | 认证 |
|------|------|------|
| `GET /api/v1/health` | 基本健康状态 | 无 |
| `GET /api/v1/health/detailed` | 含依赖服务状态 | 需要 |
| `GET /api/v1/health/ready` | 就绪检查（DB 连接） | 无 |
| `GET /api/v1/health/live` | 存活检查（进程响应） | 无 |

（端点详细规格未单独成文档；如需扩展可读 `backend/src/modules/.../health.controller.ts`。）
