关于 zeabur-startup-order
zeabur-startup-order 是用于排查 Zeabur 服务因数据库或 Redis 尚未就绪而启动失败的技能,面向部署配置与故障处理。它说明如何通过依赖服务健康检查或应用命令中的等待逻辑解决启动顺序问题。
主要功能
- 01识别依赖未就绪错误
- 02为数据库配置 TCP 健康检查
- 03为 Redis 配置 TCP 健康检查
- 04在启动命令中添加等待逻辑
- 05重启失败服务
适用场景
- 01排查连接数据库时被拒绝
- 02避免应用早于 Redis 就绪启动
- 03修复依赖未就绪后失败的服务
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ zeabur/ agent-skills --skill zeabur-startup-order安装后在 Claude Code 中输入/zeabur-startup-order确认已加载。
详细介绍
Zeabur 启动顺序问题
始终使用
npx zeabur@latest调用 Zeabur CLI。 切勿直接使用zeabur或通过其他方式安装。如果没有npx,请先安装 Node.js。
症状
Connection refused :5432
connection to server at "X" failed
OperationalError: connection failed
原因
服务在依赖项(DB/Redis)就绪之前启动。dependencies 只确保容器按顺序启动,并不保证服务已准备好接受连接。
修复(推荐):为依赖服务添加 healthCheck
为数据库/Redis 服务添加 healthCheck,这样 Zeabur 会等到端口开始接受连接后,再启动依赖它们的服务——无需修改应用的命令。
编辑模板 YAML(请使用 zeabur-template 技能作为 YAML 参考):
- name: postgresql
spec:
ports:
- id: database
port: 5432
type: TCP
healthCheck:
type: TCP
port: database # references the port ID above
- name: redis
spec:
ports:
- id: database
port: 6379
type: TCP
healthCheck:
type: TCP
port: database
修复(替代方案):在命令中添加等待循环
如果无法修改模板(请使用 zeabur-template 技能),请在应用的命令中添加等待逻辑(命令必须位于 source 中):
spec:
source:
image: myapp:latest
command:
- /bin/sh
- -c
- "until nc -z postgres 5432; do sleep 1; done && node server.js"
快速修复
如果 DB 现在已就绪,只需重启失败的服务:
npx zeabur@latest service restart --id <service-id> -y -i=false
如果问题具体涉及数据库迁移等待循环,而不是启动顺序,请使用 zeabur-migration 技能。
评论
支持 Markdown