Documentation
¶
Overview ¶
Package botdist 实现 bot-worker dist 的自愈下发(FR-308,见 ADR-072): Worker 启动后经既有 CP gRPC 通道拉取内嵌归档,物化到 <dataroot>/opt/bot-worker/。 运行时依赖不随归档分发,由 FR-307 节点受控项目根提供;ESM 经 node_modules 链接解析。
Index ¶
- func CheckDeps(distDir string) error
- func Ensure(ctx context.Context, opts Options) (string, error)
- func GlobalNodeModulesCandidates(runtimesRoot string) []string
- func GlobalNodeModulesDir(runtimesRoot string) string
- func NodePathEnv(candidates []string) string
- func RefreshNodeModulesLink(distDir, runtimesRoot string) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDeps ¶
CheckDeps spawn 前只预检 ESM 从入口脚本目录向上的 node_modules 祖先链。 裸受控根必须先经链接进入这条可见路径,不能作为额外候选直接放行。
func Ensure ¶
Ensure 自愈 bot-worker dist:与 CP 内嵌归档比对指纹,不一致则拉取并原子换新, 每次都补齐 node_modules 链接。返回入口脚本绝对路径(<Dir>/index.js)。 CP 不可达或未内嵌时回退本地已有物化副本(有则用、无则报错),不阻断 Worker 启动。
func GlobalNodeModulesCandidates ¶
GlobalNodeModulesCandidates 返回链接选择与 NODE_PATH 候选,新受控根在前、旧真全局目录在后。
func GlobalNodeModulesDir ¶
GlobalNodeModulesDir 返回节点受控依赖根的 node_modules 链接目标(见 ADR-072)。 只有新根包含完整 Bot 依赖时才切换;否则继续兼容完整的旧 npm 真全局根。
func NodePathEnv ¶
NodePathEnv 组装 NODE_PATH 环境变量(CJS 依赖解析兜底;ESM 靠 node_modules 链接)。
func RefreshNodeModulesLink ¶ added in v0.18.0
RefreshNodeModulesLink 按当前新旧根完整性刷新受控 dist 的 ESM 依赖链接。 新根未完整时继续沿用完整旧根,避免安装中间态切断既有 Bot。
Types ¶
type Options ¶
type Options struct {
// CPAddr Control Plane gRPC 地址(与注册/心跳同源)。
CPAddr string
// NodeUUID / NodeSecret 节点身份(CP 侧与重注册同源校验)。
NodeUUID string
NodeSecret string
// Dir 物化目标目录(<dataroot>/opt/bot-worker)。
Dir string
// GlobalNodeModules node_modules 链接目标(FR-307 托管全局包的 node_modules 布局目录)。
GlobalNodeModules string
// contains filtered or unexported fields
}
Options 自愈参数。