Documentation ¶
Index ¶
- type Proc
- func (proc *Proc) AddRestart()
- func (proc *Proc) Delete() error
- func (proc *Proc) ForceStop() error
- func (proc *Proc) GetErrFile() string
- func (proc *Proc) GetName() string
- func (proc *Proc) GetOutFile() string
- func (proc *Proc) GetPath() string
- func (proc *Proc) GetPid() int
- func (proc *Proc) GetPidFile() string
- func (proc *Proc) GetStatus() *ProcStatus
- func (proc *Proc) GracefullyStop() error
- func (proc *Proc) Identifier() string
- func (proc *Proc) IsAlive() bool
- func (proc *Proc) NotifyStopped()
- func (proc *Proc) ResetUpTime()
- func (proc *Proc) Restart() error
- func (proc *Proc) SetStatus(status string)
- func (proc *Proc) SetSysInfo()
- func (proc *Proc) SetUptime()
- func (proc *Proc) ShouldKeepAlive() bool
- func (proc *Proc) Start() error
- func (proc *Proc) Watch() (*os.ProcessState, error)
- type ProcContainer
- type ProcStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proc ¶
type Proc struct { Name string Cmd string Args []string Path string Pidfile string Outfile string Errfile string KeepAlive bool Pid int Status *ProcStatus // contains filtered or unexported fields }
Proc is a os.Process wrapper with Status and more info that will be used on Master to maintain the process health.
func (*Proc) AddRestart ¶
func (proc *Proc) AddRestart()
AddRestart is add one restart to proc status
func (*Proc) Delete ¶
Delete will delete everything created by this process, including the out, err and pid file. Returns an error in case there's any.
func (*Proc) ForceStop ¶
ForceStop will forcefully send a SIGKILL signal to process killing it instantly. Returns an error in case there's any.
func (*Proc) GetErrFile ¶
GetErrFile will return proc error file
func (*Proc) GetOutFile ¶
GetOutFile will return proc out file
func (*Proc) GetPidFile ¶
GetPidFile will return proc pid file
func (*Proc) GetStatus ¶
func (proc *Proc) GetStatus() *ProcStatus
GetStatus will return proc current status
func (*Proc) GracefullyStop ¶
GracefullyStop will send a SIGTERM signal asking the process to terminate. The process may choose to die gracefully or ignore this signal completely. In that case the process will keep running unless you call ForceStop() Returns an error in case there's any.
func (*Proc) Identifier ¶
Identifier is that will be used by watcher to keep track of its processes
func (*Proc) IsAlive ¶
IsAlive will check if the process is alive or not. Returns true if the process is alive or false otherwise.
func (*Proc) NotifyStopped ¶
func (proc *Proc) NotifyStopped()
NotifyStopped that process was stopped so we can set its PID to -1
func (*Proc) Restart ¶
Restart will try to gracefully stop the process and then Start it again. Returns an error in case there's any.
func (*Proc) SetSysInfo ¶
func (proc *Proc) SetSysInfo()
SetSysInfo will get current proc cpu and memory usage
func (*Proc) ShouldKeepAlive ¶
ShouldKeepAlive will returns true if the process should be kept alive or not
type ProcContainer ¶
type ProcContainer interface { Start() error ForceStop() error GracefullyStop() error Restart() error Delete() error IsAlive() bool Identifier() string ShouldKeepAlive() bool AddRestart() NotifyStopped() SetStatus(status string) SetUptime() SetSysInfo() GetPid() int GetStatus() *ProcStatus Watch() (*os.ProcessState, error) GetOutFile() string GetPidFile() string GetPath() string GetErrFile() string GetName() string // contains filtered or unexported methods }
ProcContainer is a interface that about proc
type ProcStatus ¶
type ProcStatus struct { Status string Restarts int StartTime int64 Uptime string Sys *pidusage.SysInfo }
ProcStatus is a wrapper with the process current status.
func (*ProcStatus) AddRestart ¶
func (proc_status *ProcStatus) AddRestart()
AddRestart will add one restart to the process status.
func (*ProcStatus) InitUptime ¶
func (proc_status *ProcStatus) InitUptime()
InitUptime will record proc start time
func (*ProcStatus) ResetUptime ¶
func (proc_status *ProcStatus) ResetUptime()
ResetUptime will Reset uptime
func (*ProcStatus) SetStatus ¶
func (proc_status *ProcStatus) SetStatus(status string)
SetStatus will set the process string status.
func (*ProcStatus) SetSysInfo ¶
func (proc_status *ProcStatus) SetSysInfo(pid int)
SetSysInfo will get current proc cpu and memory usage
func (*ProcStatus) SetUptime ¶
func (proc_status *ProcStatus) SetUptime()
SetUptime will figure out process uptime