📦 Service Catalog — 服务 Cata记录
v1.0.0Auto-discover and cata记录 all 服务s in a codebase or organization — 扫描 Dockerfiles, docker-compose, Kubernetes manifests, package.json, 系统d units, P...
详细分析 ▾
运行时依赖
版本
运行 in CI to catch undocumented infrastructure changes.
安装命令
点击复制技能文档
服务目录 通过扫描基础设施即代码、配置文件与项目元数据,构建并持续维护一份全景服务目录。回答“我们运行哪些服务、谁负责、依赖什么、是否健康?”
适用场景 “列出所有服务”、“我们有哪些微服务”、“服务清单”、“谁负责这个服务”、“绘制基础设施图”、“服务依赖”、“平台工程审计”或搭建内部开发者门户。
命令
- discover — 自动发现服务
Docker 服务 # Docker Compose 服务 find . -maxdepth 4 \( -name "docker-compose.yml" -o -name "docker-compose.yaml" -o -name "compose.yml" -o -name "compose.yaml" \) \ -not -path '/node_modules/' -not -path '/.git/' 2>/dev/null | while read f; do echo "=== $f ===" python3 -c "..." 2>/dev/null || grep -E '^\s{2}\w+:' "$f" | grep -v '^\s{4}' | sed 's/://;s/^\s/ Service: /' done
# Dockerfiles(通常一个文件对应一个服务) find . -maxdepth 4 \( -name "Dockerfile" -o -name "Dockerfile." -o -name ".Dockerfile" \) \ -not -path '/node_modules/' -not -path '/.git/' 2>/dev/null | while read f; do DIR=$(dirname "$f") BASE=$(head -5 "$f" | grep -oP '(?<=FROM )\S+' | head -1) echo "Dockerfile: $f (base: ${BASE:-unknown}) — dir: $DIR" done
Kubernetes 清单 # K8s Deployment、StatefulSet、Service、CronJob 等 find . -maxdepth 5 -name ".yaml" -o -name ".yml" | \ xargs grep -l "kind:\s\(Deployment\|StatefulSet\|Service\|CronJob\|DaemonSet\|Job\)" 2>/dev/null | \ grep -v node_modules | while read f; do echo "=== $f ==="; grep -E "^\s(kind|name|namespace|image):" "$f" | head -10 done
Helm Charts find . -maxdepth 4 -name "Chart.yaml" -not -path '/node_modules/' 2>/dev/null | while read f; do echo "=== Helm Chart: $f ==="; grep -E "^(name|version|description|appVersion):" "$f" done
应用配置 # Node.js 服务(package.json 含 start 脚本) find . -maxdepth 3 -name "package.json" -not -path '/node_modules/' 2>/dev/null | while read f; do HAS_START=$(python3 -c "..." 2>/dev/null) if [ "$HAS_START" = "yes" ]; then NAME=$(python3 -c "..." 2>/dev/null) echo "Node service: $NAME ($f)" fi done
# Python 服务(含主入口) find . -maxdepth 3 -name "pyproject.toml" -not -path '/vendor/' 2>/dev/null | while read f; do DIR=$(dirname "$f"); echo "Python project: $f"; grep -E "^(name|version)" "$f" | head -2 done
# Go 服务 find . -maxdepth 3 -name "go.mod" 2>/dev/null | while read f; do MODULE=$(head -1 "$f" | awk '{print $2}'); echo "Go module: $MODULE ($f)" done
# Procfile(Heroku/Dokku) find . -maxdepth 3 -name "Procfile" 2>/dev/null | while read f; do echo "=== Procfile: $f ==="; cat "$f"; done
# Systemd 单元 find . -maxdepth 4 -name ".service" -not -path '/.git/' 2>/dev/null | while read f; do echo "Systemd unit: $f"; grep -E "^(Description|ExecStart|After|Requires)=" "$f" 2>/dev/null done
CI/CD 流水线(暴露已部署服务) # GitHub Actions 部署工作流 find .github/workflows -name ".yml" -o -name ".yaml" 2>/dev/null | \ xargs grep -l "deploy" 2>/dev/null | while read f; do echo "Deploy workflow: $f"; grep -E "^\s*(name|runs-on|env):" "$f" | head -5 done
# GitLab CI 部署阶段 grep -A5 "deploy" .gitlab-ci.yml 2>/dev/null | head -20
- catalog — 生成服务目录
# 从环境变量与配置检测服务依赖 rg -n "(DATABASE_URL|REDIS_URL|RABBITMQ_URL|KAFKA_BROKERS|MONGO_URI|API_URL|SERVICE_URL)" \ -g '!node_modules' -g '!vendor' -g '!dist' --type-not binary 2>/dev/null
# 检测服务间调用 rg -n "(fetch|axios|ht