Documentation
¶
Index ¶
- Constants
- func DisableDebug()
- func EnableDebug()
- func Reap()
- func ReapZombie()
- func Start(config Config)
- type Config
- type Entry
- func (that *Entry) Args() []string
- func (that *Entry) AutoReStart(defVal string) string
- func (that *Entry) AutoStart() bool
- func (that *Entry) Command() string
- func (that *Entry) CreateCommand() (*exec.Cmd, error)
- func (that *Entry) Directory() string
- func (that *Entry) Environment() []string
- func (that *Entry) ExitCodes(defaultVal string) string
- func (that *Entry) Extend(key string, defVal string) string
- func (that *Entry) KillAsGroup() bool
- func (that *Entry) KillWaitSecs(defaultVal int) int
- func (that *Entry) Name() string
- func (that *Entry) Priority() int
- func (that *Entry) RedirectStderr() bool
- func (that *Entry) RestartPause() int
- func (that *Entry) SetArgs(args []string)
- func (that *Entry) SetAutoReStart(val string)
- func (that *Entry) SetAutoStart(autoStart bool)
- func (that *Entry) SetCommand(command string)
- func (that *Entry) SetDirectory(directory string)
- func (that *Entry) SetEnvironment(environment []string)
- func (that *Entry) SetExitCodes(val string)
- func (that *Entry) SetExtend(key string, val string)
- func (that *Entry) SetKillAsGroup(killAsGroup bool)
- func (that *Entry) SetKillWaitSecs(killWaitSecs int)
- func (that *Entry) SetName(name string)
- func (that *Entry) SetPriority(priority int)
- func (that *Entry) SetRedirectStderr(v bool)
- func (that *Entry) SetRestartPause(restartPause int)
- func (that *Entry) SetStartRetries(startRetries int)
- func (that *Entry) SetStartSecs(startSecs int)
- func (that *Entry) SetStderrLogFileBackups(v int)
- func (that *Entry) SetStderrLogFileMaxBytes(v string)
- func (that *Entry) SetStderrLogfile(v string)
- func (that *Entry) SetStdoutLogFileBackups(v int)
- func (that *Entry) SetStdoutLogFileMaxBytes(v string)
- func (that *Entry) SetStdoutLogfile(v string)
- func (that *Entry) SetStopAsGroup(stopAsGroup bool)
- func (that *Entry) SetStopSignal(stopSignal string)
- func (that *Entry) SetStopWaitSecs(stopWaitSecs int)
- func (that *Entry) SetUser(user string)
- func (that *Entry) StartRetries() int
- func (that *Entry) StartSecs() int
- func (that *Entry) StderrLogFileBackups(defaultVal int) int
- func (that *Entry) StderrLogFileMaxBytes(defaultVal int) int
- func (that *Entry) StderrLogfile(defaultVal string) string
- func (that *Entry) StdoutLogFileBackups(defaultVal int) int
- func (that *Entry) StdoutLogFileMaxBytes(defaultVal int) int
- func (that *Entry) StdoutLogfile(defaultVal string) string
- func (that *Entry) StopAsGroup() bool
- func (that *Entry) StopSignal() string
- func (that *Entry) StopWaitSecs(defaultVal int) int
- func (that *Entry) User() string
- type Info
- type Manager
- func (that *Manager) Add(name string, proc *Process)
- func (that *Manager) Clear()
- func (that *Manager) Find(name string) *Process
- func (that *Manager) ForEachProcess(procFunc func(p *Process))
- func (that *Manager) GetAllProcessInfo() ([]*Info, error)
- func (that *Manager) GetProcessInfo(name string) (*Info, error)
- func (that *Manager) NewProcess(path string, args []string, environment []string) (*Process, error)
- func (that *Manager) NewProcessByEntry(entry *Entry) (*Process, error)
- func (that *Manager) NewProcessCmd(cmd string, environment ...[]string) (*Process, error)
- func (that *Manager) Remove(name string) *Process
- func (that *Manager) StartProcess(name string, wait bool) (bool, error)
- func (that *Manager) StopAllProcesses()
- func (that *Manager) StopProcess(name string, wait bool) (bool, error)
- type Process
- func (that *Process) GetDescription() string
- func (that *Process) GetExitStatus() int
- func (that *Process) GetName() string
- func (that *Process) GetProcessInfo() *Info
- func (that *Process) GetStartTime() time.Time
- func (that *Process) GetState() State
- func (that *Process) GetStatus() string
- func (that *Process) GetStderrLogfile() string
- func (that *Process) GetStdoutLogfile() string
- func (that *Process) GetStopTime() time.Time
- func (that *Process) Pid() int
- func (that *Process) Signal(sig os.Signal, sigChildren bool) error
- func (that *Process) Start(wait bool)
- func (that *Process) Stop(wait bool)
- type State
Constants ¶
const ( // Stopped 已停止 Stopped State = iota // Starting 启动中 Starting = 10 // Running 运行中 Running = 20 // Backoff 已挂起 Backoff = 30 // Stopping 停止中 Stopping = 40 // Exited 已退出 Exited = 100 // Fatal 启动失败 Fatal = 200 // Unknown 未知状态 Unknown = 1000 )
Variables ¶
This section is empty.
Functions ¶
func DisableDebug ¶
func DisableDebug()
func EnableDebug ¶
func EnableDebug()
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func (*Entry) AutoReStart ¶
AutoReStart 值为 true,false,unexpected
func (*Entry) CreateCommand ¶
CreateCommand 根据就配置生成cmd对象
func (*Entry) KillAsGroup ¶
KillAsGroup 强制杀死进程的时候,是否向该进程的进程组发送kill信号
func (*Entry) KillWaitSecs ¶
KillWaitSecs 强杀进程等待秒数
func (*Entry) RedirectStderr ¶
RedirectStderr 是否重写标准错误输出到标准输出
func (*Entry) SetAutoReStart ¶
SetAutoReStart 设置自动重启 值为 true,false,unexpected
func (*Entry) SetAutoStart ¶
SetAutoStart 设置程序是否需要自动启动
func (*Entry) SetDirectory ¶
SetDirectory 设置程序运行目录
func (*Entry) SetEnvironment ¶
SetEnvironment 设置当前进程的环境变量
func (*Entry) SetExitCodes ¶
SetExitCodes 设置退出code的值列表,格式为 1,2,3,4
func (*Entry) SetKillAsGroup ¶
SetKillAsGroup 强制杀死进程的时候,是否向该进程的进程组发送kill信号
func (*Entry) SetKillWaitSecs ¶
SetKillWaitSecs 强杀进程等待秒数
func (*Entry) SetRedirectStderr ¶
SetRedirectStderr 是否重写标准错误输出到标准输出
func (*Entry) SetRestartPause ¶
SetRestartPause 设置进程重启间隔秒数
func (*Entry) SetStartRetries ¶
SetStartRetries 设置启动失败自动重试次数
func (*Entry) SetStartSecs ¶
SetStartSecs 指定启动多少秒后没有异常退出,则表示启动成功 未设置该值,则表示cmd.Start方法调用为出错,则表示启动成功, 设置了该值,则表示程序启动后需稳定运行指定的秒数后才算启动成功
func (*Entry) SetStderrLogFileBackups ¶
SetStderrLogFileBackups 设置标准错误输出的log文件如果达到了最大容量
func (*Entry) SetStderrLogFileMaxBytes ¶
SetStderrLogFileMaxBytes 设置标准错误输出的log文件最大容量,格式:5KB,10MB,2GB,默认是50MB
func (*Entry) SetStderrLogfile ¶
SetStderrLogfile 设置标准错误输出的log文件地址
func (*Entry) SetStdoutLogFileBackups ¶
SetStdoutLogFileBackups 标准输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*Entry) SetStdoutLogFileMaxBytes ¶
SetStdoutLogFileMaxBytes 设置标准输出的log文件最大容量,格式:5KB,10MB,2GB,默认是50MB
func (*Entry) SetStdoutLogfile ¶
SetStdoutLogfile 设置标准输出的log文件地址
func (*Entry) SetStopAsGroup ¶
SetStopAsGroup 停止进程的时候,是否向该进程组发送停止信号
func (*Entry) SetStopSignal ¶
SetStopSignal 正常结束进程是否需要发送的信号
func (*Entry) SetStopWaitSecs ¶
SetStopWaitSecs 发送结束进程的信号后等待的秒数
func (*Entry) StderrLogFileBackups ¶
StderrLogFileBackups 标准错误输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*Entry) StderrLogFileMaxBytes ¶
StderrLogFileMaxBytes 标准错误输出的log文件最大容量,大于这个容量会分包
func (*Entry) StderrLogfile ¶
StderrLogfile 标准错误输出的log文件地址
func (*Entry) StdoutLogFileBackups ¶
StdoutLogFileBackups 标准输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*Entry) StdoutLogFileMaxBytes ¶
StdoutLogFileMaxBytes 标准输出的log文件最大容量,大于这个容量会分包
func (*Entry) StdoutLogfile ¶
StdoutLogfile 标准输出的log文件地址
func (*Entry) StopWaitSecs ¶
StopWaitSecs 发送结束进程的信号后等待的秒数
type Info ¶
type Info struct { Name string `json:"name"` Description string `json:"description"` Start int `json:"start"` Stop int `json:"stop"` Now int `json:"now"` State int `json:"state"` StateName string `json:"statename"` SpawnErr string `json:"spawnerr"` ExitStatus int `json:"exitstatus"` Logfile string `json:"logfile"` StdoutLogfile string `json:"stdout_logfile"` StderrLogfile string `json:"stderr_logfile"` Pid int `json:"pid"` }
Info 进程的运行状态
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) ForEachProcess ¶
ForEachProcess 迭代进程列表
func (*Manager) GetAllProcessInfo ¶
GetAllProcessInfo 获取所有进程信息
func (*Manager) GetProcessInfo ¶
GetProcessInfo 获取指定进程名的进程信息
func (*Manager) NewProcess ¶
NewProcess 创建进程 path: 可执行文件路径 args: 参数 environment: 环境变量
func (*Manager) NewProcessByEntry ¶
NewProcessByEntry 创建进程 entry: 配置对象
func (*Manager) NewProcessCmd ¶
NewProcessCmd 创建进程 path: shell命令 environment: 环境变量
func (*Manager) StartProcess ¶
StartProcess 启动指定进程
type Process ¶
type Process struct { // 进程管理对象 Manager *Manager StdoutLog proclog.Logger StderrLog proclog.Logger // contains filtered or unexported fields }
func NewProcess ¶
NewProcess 创建进程对象
func NewProcessByEntry ¶
NewProcessByEntry 通过详细配置,创建进程对象
func NewProcessCmd ¶
NewProcessCmd 按命令启动
func (*Process) GetStderrLogfile ¶
GetStderrLogfile 获取标准错误将要写入的日志文件
func (*Process) GetStdoutLogfile ¶
GetStdoutLogfile 获取标准输出将要写入的日志文件