cmd

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnSupportWin = errors.New("un support on windows")
)

Functions

func DumpCfg

func DumpCfg(path string, cfg interface{}) error

会覆盖写入

func GetCfgPath

func GetCfgPath(item1, item2 string) string

func GetLocalCfg

func GetLocalCfg(name string) string

func GetSrvPath

func GetSrvPath(name string) string

func HandleExitCoder

func HandleExitCoder(err error)

func LoadCfg

func LoadCfg(path string, cfg interface{})

func NewCli

func NewCli(appName string, cfgArgs ...interface{}) *cli.App

Types

type ExitCoder

type ExitCoder interface {
	error
	ExitCode() int
}

type Service

type Service interface {
	// 设置最多重试次数
	SetExecMax(uint)
	// 设置服务停止触发函数
	SetStopFunc(func())

	Run()
}

func NewSrv

func NewSrv(app *cli.App, runnerFunc cli.ActionFunc, cfgArgs ...interface{}) (Service, error)

与 urfave/cli 配合使用 runnerFunc 是 服务的阻塞启动程序,函数如果执行完会自动重新执行, 间隔时间1ms开始指数增长 cfgArgs 是参数的相关配置, 第一项是cfg,是个可以序列化的对象, 第二项是cfgFilePath, 字符串 cfg 是 参数对象, cfgFilePath 是参数文件地址, install 时 创建该文件,并填入cfg中数据, cfg 为空则不创建, cfgFilePath 为空则在默认位置创建 默认位置 `C:\Program Files\name\name.yml` 或者 /etc/name/name.yaml

Jump to

Keyboard shortcuts

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