Documentation
¶
Overview ¶
Package proc 托管外部可执行文件(frpc、cloudflared、tailscaled 等): 查找二进制、后台运行、异常退出自动重启、把输出写入模块日志。
Index ¶
- func Clean(line string) string
- func Output(timeout time.Duration, path string, args, env []string) ([]byte, error)
- func Resolve(configured, configDir string, names ...string) (string, error)
- func Run(ctx context.Context, spec Spec, log *logbuf.Logger) error
- func Version(path string, args ...string) string
- type Spec
- type State
- type Supervisor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Spec ¶
type Spec struct {
Path string
Args []string
// Env 追加到当前进程环境变量之后,用于传递令牌等不宜出现在命令行的参数
Env []string
Dir string
// OnLine 在每行输出(已去除颜色码与时间戳)到达时调用,可为 nil
OnLine func(line string)
// OnStart 在进程每次成功启动后调用,可为 nil
OnStart func()
}
Spec 描述要运行的进程。
type State ¶
type State struct {
Running bool `json:"running"`
PID int `json:"pid,omitempty"`
Since time.Time `json:"since,omitempty"`
Restarts int `json:"restarts"`
// LastExit 记录最近一次退出原因
LastExit string `json:"lastExit,omitempty"`
// Error 非空表示无法启动(例如二进制不存在),不会自动重试
Error string `json:"error,omitempty"`
}
State 是进程运行状态。
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor 托管一个长期运行的进程。
Click to show internal directories.
Click to hide internal directories.