master

package
v1.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FlagParser 可由 App 指定自定义的 flag
	FlagParser = flagParse

	Daemon  bool
	Version bool
)
View Source
var (
	// ConfigModTime 公共配置文件集最后修改时间
	ConfigModTime time.Time

	// ConfigLoadTime 配置文件最后加载时间
	ConfigLoadTime time.Time

	// MainWatcherKey 主程序二进制和配置文件监控器标识
	MainWatcherKey     = "__PKG_MAIN_BIN_WATCHER__"
	MainWatcherConfKey = "__PKG_MAIN_CONFIG_WATCHER__"
)

Functions

func DebVersion

func DebVersion(name string) string

DebVersion 查询完整Debian版本, 保留公开签名; 非Linux、缺包或查询失败返回空字符串.

func DebVersionByService

func DebVersionByService(name string) string

DebVersionByService 沿用既有服务名到包名的转换, 不安装或修复包.

func GetRemoteConf

func GetRemoteConf(ctx context.Context, cfg config.FilesConf)

GetRemoteConf 定时获取远端配置, 配合 RemotePipelines 使用. 主配置变化时旧循环应在随机等待和周期等待期间响应 ctx 取消并退出, 避免与新 fetcher 重叠写同一文件.

func MD5ConfigFiles

func MD5ConfigFiles() (md5 string, confFiles []string)

MD5ConfigFiles 配置文件 MD5, 有变化时重载系统配置项

func MD5Files

func MD5Files(files ...string) (md5 string)

MD5Files 文件 MD5

func Main

func Main()

Main 带默认命令行参数启动

func Register

func Register(stage Stage, sf ...Pipeline)

func RegisterWithContext

func RegisterWithContext(stage Stage, sf ...ContextFunc)

func Run

func Run()

Run 守护进程启动程序

func SetExtraWatcherFiles added in v0.8.1

func SetExtraWatcherFiles(confFile ...string)

SetExtraWatcherFiles 设置额外的文件到内容变化监控列表

func Start added in v0.0.10

func Start()

Start 执行程序初始化

func Stop added in v0.0.10

func Stop()

Stop 取消安装器的本地等待后退出业务, 不等待或强杀已运行的包管理命令.

func WaitUntilNtpdate added in v0.6.10

func WaitUntilNtpdate(timeout time.Duration) bool

WaitUntilNtpdate 等待, 直到第一次时间同步成功

Types

type ContextFunc

type ContextFunc func(ctx context.Context)

type Pipeline added in v0.0.10

type Pipeline interface {
	Start() error
	Runtime() error
	Stop() error
}

type Stage

type Stage int
const (
	// ConfigStage 程序启动和配置重载时优先执行
	ConfigStage Stage = iota

	// MainStage 在 ConfigStage 执行完成后执行
	MainStage

	// RemoteStage 执行定时远程获取配置
	RemoteStage
)

type Watcher

type Watcher struct {
	// 监控器标识
	Key string

	// 待监控的文件列表
	Files []string

	// 文件列表中文件内容变化时执行
	Func func()

	// 始终执行, 不关注文件内容是否变化
	Always bool

	// 基于文件内容是否变化的标记生成函数, 默认为: MD5Files
	HashGenerator func(...string) string
}

Watcher 文件变化监控器

func (Watcher) Start

func (w Watcher) Start()

func (Watcher) Stop

func (w Watcher) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL