Documentation
¶
Index ¶
- Constants
- func DisableDebug()
- func EnableDebug()
- func Reap()
- func ReapZombie()
- func Start(config Config)
- type Config
- 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 ProcEntry
- func (that *ProcEntry) Args() []string
- func (that *ProcEntry) AutoReStart(defVal string) string
- func (that *ProcEntry) AutoStart() bool
- func (that *ProcEntry) Command() string
- func (that *ProcEntry) CreateCommand() (*exec.Cmd, error)
- func (that *ProcEntry) Directory() string
- func (that *ProcEntry) Environment() []string
- func (that *ProcEntry) ExitCodes(defaultVal string) string
- func (that *ProcEntry) Extend(key string, defVal string) string
- func (that *ProcEntry) KillAsGroup() bool
- func (that *ProcEntry) KillWaitSecs(defaultVal int) int
- func (that *ProcEntry) Name() string
- func (that *ProcEntry) Priority() int
- func (that *ProcEntry) RedirectStderr() bool
- func (that *ProcEntry) RestartPause() int
- func (that *ProcEntry) SetArgs(args []string)
- func (that *ProcEntry) SetAutoReStart(val string)
- func (that *ProcEntry) SetAutoStart(autoStart bool)
- func (that *ProcEntry) SetCommand(command string)
- func (that *ProcEntry) SetDirectory(directory string)
- func (that *ProcEntry) SetEnvironment(environment []string)
- func (that *ProcEntry) SetExitCodes(val string)
- func (that *ProcEntry) SetExtend(key string, val string)
- func (that *ProcEntry) SetKillAsGroup(killAsGroup bool)
- func (that *ProcEntry) SetKillWaitSecs(killWaitSecs int)
- func (that *ProcEntry) SetName(name string)
- func (that *ProcEntry) SetPriority(priority int)
- func (that *ProcEntry) SetRedirectStderr(v bool)
- func (that *ProcEntry) SetRestartPause(restartPause int)
- func (that *ProcEntry) SetStartRetries(startRetries int)
- func (that *ProcEntry) SetStartSecs(startSecs int)
- func (that *ProcEntry) SetStderrLogFileBackups(v int)
- func (that *ProcEntry) SetStderrLogFileMaxBytes(v string)
- func (that *ProcEntry) SetStderrLogfile(v string)
- func (that *ProcEntry) SetStdoutLogFileBackups(v int)
- func (that *ProcEntry) SetStdoutLogFileMaxBytes(v string)
- func (that *ProcEntry) SetStdoutLogfile(v string)
- func (that *ProcEntry) SetStopAsGroup(stopAsGroup bool)
- func (that *ProcEntry) SetStopSignal(stopSignal string)
- func (that *ProcEntry) SetStopWaitSecs(stopWaitSecs int)
- func (that *ProcEntry) SetUser(user string)
- func (that *ProcEntry) StartRetries() int
- func (that *ProcEntry) StartSecs() int
- func (that *ProcEntry) StderrLogFileBackups(defaultVal int) int
- func (that *ProcEntry) StderrLogFileMaxBytes(defaultVal int) int
- func (that *ProcEntry) StderrLogfile(defaultVal string) string
- func (that *ProcEntry) StdoutLogFileBackups(defaultVal int) int
- func (that *ProcEntry) StdoutLogFileMaxBytes(defaultVal int) int
- func (that *ProcEntry) StdoutLogfile(defaultVal string) string
- func (that *ProcEntry) StopAsGroup() bool
- func (that *ProcEntry) StopSignal() string
- func (that *ProcEntry) StopWaitSecs(defaultVal int) int
- func (that *ProcEntry) User() string
- 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 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 ProcEntry ¶ added in v0.0.8
type ProcEntry struct {
// contains filtered or unexported fields
}
func NewProcEntry ¶ added in v0.0.8
NewProcEntry 创建进程启动配置
func NewProcEntryByConfigEntry ¶ added in v0.0.8
NewProcEntryByConfigEntry 通过配置文件解析生成proc entry对象
func (*ProcEntry) AutoReStart ¶ added in v0.0.8
AutoReStart 值为 true,false,unexpected
func (*ProcEntry) CreateCommand ¶ added in v0.0.8
CreateCommand 根据就配置生成cmd对象
func (*ProcEntry) Environment ¶ added in v0.0.8
Environment 获取当前进程的环境变量
func (*ProcEntry) KillAsGroup ¶ added in v0.0.8
KillAsGroup 强制杀死进程的时候,是否向该进程的进程组发送kill信号
func (*ProcEntry) KillWaitSecs ¶ added in v0.0.8
KillWaitSecs 强杀进程等待秒数
func (*ProcEntry) RedirectStderr ¶ added in v0.0.8
RedirectStderr 是否重写标准错误输出到标准输出
func (*ProcEntry) RestartPause ¶ added in v0.0.8
RestartPause 进程重启间隔秒数,默认是0,表示不间隔
func (*ProcEntry) SetAutoReStart ¶ added in v0.0.8
SetAutoReStart 设置自动重启 值为 true,false,unexpected
func (*ProcEntry) SetAutoStart ¶ added in v0.0.8
SetAutoStart 设置程序是否需要自动启动
func (*ProcEntry) SetCommand ¶ added in v0.0.8
SetCommand 设置启动命令
func (*ProcEntry) SetDirectory ¶ added in v0.0.8
SetDirectory 设置程序运行目录
func (*ProcEntry) SetEnvironment ¶ added in v0.0.8
SetEnvironment 设置当前进程的环境变量
func (*ProcEntry) SetExitCodes ¶ added in v0.0.8
SetExitCodes 设置退出code的值列表,格式为 1,2,3,4
func (*ProcEntry) SetKillAsGroup ¶ added in v0.0.8
SetKillAsGroup 强制杀死进程的时候,是否向该进程的进程组发送kill信号
func (*ProcEntry) SetKillWaitSecs ¶ added in v0.0.8
SetKillWaitSecs 强杀进程等待秒数
func (*ProcEntry) SetPriority ¶ added in v0.0.8
SetPriority 设置进程启动优先级
func (*ProcEntry) SetRedirectStderr ¶ added in v0.0.8
SetRedirectStderr 是否重写标准错误输出到标准输出
func (*ProcEntry) SetRestartPause ¶ added in v0.0.8
SetRestartPause 设置进程重启间隔秒数
func (*ProcEntry) SetStartRetries ¶ added in v0.0.8
SetStartRetries 设置启动失败自动重试次数
func (*ProcEntry) SetStartSecs ¶ added in v0.0.8
SetStartSecs 指定启动多少秒后没有异常退出,则表示启动成功 未设置该值,则表示cmd.Start方法调用为出错,则表示启动成功, 设置了该值,则表示程序启动后需稳定运行指定的秒数后才算启动成功
func (*ProcEntry) SetStderrLogFileBackups ¶ added in v0.0.8
SetStderrLogFileBackups 设置标准错误输出的log文件如果达到了最大容量
func (*ProcEntry) SetStderrLogFileMaxBytes ¶ added in v0.0.8
SetStderrLogFileMaxBytes 设置标准错误输出的log文件最大容量,格式:5KB,10MB,2GB,默认是50MB
func (*ProcEntry) SetStderrLogfile ¶ added in v0.0.8
SetStderrLogfile 设置标准错误输出的log文件地址
func (*ProcEntry) SetStdoutLogFileBackups ¶ added in v0.0.8
SetStdoutLogFileBackups 标准输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*ProcEntry) SetStdoutLogFileMaxBytes ¶ added in v0.0.8
SetStdoutLogFileMaxBytes 设置标准输出的log文件最大容量,格式:5KB,10MB,2GB,默认是50MB
func (*ProcEntry) SetStdoutLogfile ¶ added in v0.0.8
SetStdoutLogfile 设置标准输出的log文件地址
func (*ProcEntry) SetStopAsGroup ¶ added in v0.0.8
SetStopAsGroup 停止进程的时候,是否向该进程组发送停止信号
func (*ProcEntry) SetStopSignal ¶ added in v0.0.8
SetStopSignal 正常结束进程是否需要发送的信号
func (*ProcEntry) SetStopWaitSecs ¶ added in v0.0.8
SetStopWaitSecs 发送结束进程的信号后等待的秒数
func (*ProcEntry) StartRetries ¶ added in v0.0.8
StartRetries 启动失败自动重试次数
func (*ProcEntry) StderrLogFileBackups ¶ added in v0.0.8
StderrLogFileBackups 标准错误输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*ProcEntry) StderrLogFileMaxBytes ¶ added in v0.0.8
StderrLogFileMaxBytes 标准错误输出的log文件最大容量,大于这个容量会分包
func (*ProcEntry) StderrLogfile ¶ added in v0.0.8
StderrLogfile 标准错误输出的log文件地址
func (*ProcEntry) StdoutLogFileBackups ¶ added in v0.0.8
StdoutLogFileBackups 标准输出的log文件如果达到了最大容量,会自动分包,这个值是设置它的最大分包份数
func (*ProcEntry) StdoutLogFileMaxBytes ¶ added in v0.0.8
StdoutLogFileMaxBytes 标准输出的log文件最大容量,大于这个容量会分包
func (*ProcEntry) StdoutLogfile ¶ added in v0.0.8
StdoutLogfile 标准输出的log文件地址
func (*ProcEntry) StopAsGroup ¶ added in v0.0.8
StopAsGroup 停止进程的时候,是否向该进程组发送停止信号
func (*ProcEntry) StopSignal ¶ added in v0.0.8
StopSignal 正常结束进程是否需要发送的信号
func (*ProcEntry) StopWaitSecs ¶ added in v0.0.8
StopWaitSecs 发送结束进程的信号后等待的秒数
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 获取标准输出将要写入的日志文件