instance

package
v0.0.0-...-d47ba9e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
	 * PROCSTOPPED signifies process not currently running
	 */
	PROCSTOPPED = iota
	/*
	 * PROCRUNNING signifies process currently running
	 */
	PROCRUNNING
	/*
	 * PROCSTART signifies process beginning its start sequence
	 */
	PROCSTART
	/*
	 * PROCEXITED signifies process has ended
	 */
	PROCEXITED
	/*
	 * PROCBACKOFF signifies should not alter process
	 */
	PROCBACKOFF
	/*
	 * PROCSTOPPING signifies in process of stopping
	 */
	PROCSTOPPING
	/*
	 * PROCSTARTFAIL signifies process could not start successfully
	 */
	PROCSTARTFAIL
)
View Source
const (
	/*
	 * RESTARTALWAYS signifies restart whenever process is stopped
	 */
	RESTARTALWAYS = iota
	/*
	 * RESTARTNEVER signifies never restart process
	 */
	RESTARTNEVER
	/*
	 * RESTARTUNEXPECTED signifies restart on unexpected exit
	 */
	RESTARTUNEXPECTED
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	JobID         int
	InstanceID    int
	Args          []string
	RestartPolicy int
	ExpectedExit  int
	StartCheckup  int
	Restarts      *int32
	MaxRestarts   int32
	StopSignal    os.Signal
	StopTimeout   int
	EnvVars       []string
	WorkingDir    string
	Umask         int
	StartTime     time.Time
	StopTime      time.Time
	Status        int
	Redirections  []*os.File
	Stopped       bool
	Process       *os.Process
	Mutex         sync.RWMutex
	Condition     *sync.Cond
	State         *os.ProcessState
	Cfg           *CFG.JobConfig
	Starting      bool
	FinishedCh    chan struct{}
}

* Instance struct manages the execution of one process

func (*Instance) ChangeStatus

func (i *Instance) ChangeStatus(state int)

* ChangeStatus sets State

func (*Instance) CreateJob

func (i *Instance) CreateJob() error

* CreateJob creates & launches process

func (*Instance) GetStatus

func (i *Instance) GetStatus() string

* GetStatus return status of the process

func (*Instance) PIDExists

func (i *Instance) PIDExists() bool

* PIDExists check the existence of given process

func (*Instance) Run

func (i *Instance) Run(callback func())

* Run launches the process and monitors the start, restarting if start has * failed on successful start, waits for process to complete and sends a * Finished message on FinishedCh

func (*Instance) StartInstance

func (i *Instance) StartInstance(wait bool)

* StartInstance manages the execution of a process by launching a process by * calling instance.Run() and rerunning the process after exit if * restartPolicy == always or restartPolicy == unexpected AND the exit code does * not match the exit code specified in the config

func (*Instance) StopInstance

func (i *Instance) StopInstance(wait bool)

* StopInstance is used to stop the process by sending the specified stop signal * or the SIGKILL signal if the stop signal is not received

func (*Instance) String

func (i *Instance) String() string

* String returns the printable representation of the struct

func (*Instance) WaitForExit

func (i *Instance) WaitForExit()

* WaitForExit waits for os.Process exit and saves returned ProcessState

Jump to

Keyboard shortcuts

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