process

package
v0.0.2-0...-c69cfc8 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: MIT Imports: 5 Imported by: 12

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

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

func (proc *Proc) GetPid() int

Return proc current PID

func (*Proc) GetStatus

func (proc *Proc) GetStatus() *ProcStatus

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

Proc identifier 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()

Notify that process was stopped so we can set its PID to -1

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)

Set proc status

func (*Proc) ShouldKeepAlive

func (proc *Proc) ShouldKeepAlive() bool

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)
	GetPid() int
	GetStatus() *ProcStatus
	Watch() (*os.ProcessState, error)
	// contains filtered or unexported methods
}

type ProcStatus

type ProcStatus struct {
	Status   string
	Restarts int
}

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

func (proc_status *ProcStatus) SetStatus(status string)

SetStatus will set the process string status.

Jump to

Keyboard shortcuts

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