process

package
Version: v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 8 Imported by: 6

Documentation

Index

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

func (proc *Proc) Delete() error

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

func (proc *Proc) ForceStop() error

ForceStop will forcefully send a SIGKILL signal to process killing it instantly. Returns an error in case there's any.

func (*Proc) GetErrFile added in v0.2.0

func (proc *Proc) GetErrFile() string

GetErrFile will return proc error file

func (*Proc) GetName added in v0.2.0

func (proc *Proc) GetName() string

GetName will return current proc name

func (*Proc) GetOutFile added in v0.2.0

func (proc *Proc) GetOutFile() string

GetOutFile will return proc out file

func (*Proc) GetPath added in v0.2.0

func (proc *Proc) GetPath() string

GetPath will return proc path

func (*Proc) GetPid

func (proc *Proc) GetPid() int

GetPid will return proc current PID

func (*Proc) GetPidFile added in v0.2.0

func (proc *Proc) GetPidFile() string

GetPidFile will return proc pid file

func (*Proc) GetStatus

func (proc *Proc) GetStatus() *ProcStatus

GetStatus will return proc current status

func (*Proc) GracefullyStop

func (proc *Proc) GracefullyStop() error

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

func (proc *Proc) Identifier() string

Identifier is that will be used by watcher to keep track of its processes

func (*Proc) IsAlive

func (proc *Proc) IsAlive() bool

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) ResetUpTime

func (proc *Proc) ResetUpTime()

ResetUpTime will set Uptime

func (*Proc) Restart

func (proc *Proc) Restart() error

Restart will try to gracefully stop the process and then Start it again. Returns an error in case there's any.

func (*Proc) SetStatus

func (proc *Proc) SetStatus(status string)

SetStatus will set proc status

func (*Proc) SetSysInfo

func (proc *Proc) SetSysInfo()

SetSysInfo will get current proc cpu and memory usage

func (*Proc) SetUptime

func (proc *Proc) SetUptime()

SetUptime will set Uptime

func (*Proc) ShouldKeepAlive

func (proc *Proc) ShouldKeepAlive() bool

ShouldKeepAlive will returns true if the process should be kept alive or not

func (*Proc) Start

func (proc *Proc) Start() error

Start will execute the command Cmd that should run the process. It will also create an out, err and pidfile in case they do not exist yet. Returns an error in case there's any.

func (*Proc) Watch

func (proc *Proc) Watch() (*os.ProcessState, error)

Watch will stop execution and wait until the process change its state. Usually changing state, means that the process died. Returns a tuple with the new process state and an error in case there's any.

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

Jump to

Keyboard shortcuts

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