Documentation
¶
Overview ¶
Package xrayproc 托管 xray-core 子进程:启动/停止/配置校验重启/看门狗拉起。 结论依据《知识状态清单》A 类实测:SIGTERM 优雅退出(exit 0)、SIGKILL(137)、 `-test` 配置错误 exit 23、启动失败 exit 255、watchdog 2s 拉起。
Index ¶
- func EnsureBootstrapConfig(configPath string) (bool, error)
- type Proc
- func (p *Proc) CleanupStale()
- func (p *Proc) IsRunning() bool
- func (p *Proc) Logs(n int) (string, error)
- func (p *Proc) RestartWithConfig(configJSON string) error
- func (p *Proc) Start() error
- func (p *Proc) Status() (running bool, pid int, startedAt time.Time, uptimeSec int64)
- func (p *Proc) Stop() error
- func (p *Proc) TestConfig(path string) error
- func (p *Proc) Watchdog(stop <-chan struct{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureBootstrapConfig ¶
EnsureBootstrapConfig 配置缺失时落盘自举最小模板,返回是否实际写入。 只在文件不存在时写入,绝不覆盖已有配置;首个 push_config 到达后 RestartWithConfig 原子替换,本模板天然充当"上一份好配置"的回滚兜底(-test 失败时回滚到的就是它, xray 至少保持最小配置运行、gRPC 可连,而不是裸死)。
Types ¶
type Proc ¶
type Proc struct {
Bin string
ConfigPath string
LogPath string
PidFile string
OnRestart func() // 崩溃后被 Watchdog 成功拉起时的回调
// contains filtered or unexported fields
}
Proc 管理单个 xray 实例。
func (*Proc) CleanupStale ¶
func (p *Proc) CleanupStale()
CleanupStale 停止同配置路径的残留 xray 实例(agent 异常退出遗留的孤儿进程)。
func (*Proc) RestartWithConfig ¶
RestartWithConfig 写配置 → 校验 → 重启。
func (*Proc) TestConfig ¶
TestConfig 用 `xray -test` 校验配置(exit 0 = 通过)。
Click to show internal directories.
Click to hide internal directories.