process

package module
v0.0.0-...-c2cae38 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 23 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// Stopped the stopped state
	Stopped State = iota

	// Starting the starting state
	Starting = 10

	// Running the running state
	Running = 20

	// Backoff the backoff state
	Backoff = 30

	// Stopping the stopping state
	Stopping = 40

	// Exited the Exited state
	Exited = 100

	// Fatal the Fatal state
	Fatal = 200

	// Unknown the unknown state
	Unknown = 1000
)

Variables

This section is empty.

Functions

func AddConfigChangeMonitor

func AddConfigChangeMonitor(path string, filePattern string, fileChangeCb func(path string, mode filechangemonitor.FileChangeMode))

AddConfigChangeMonitor adds program change listener to monitor if any of its configuration files is changed

func AddProgramChangeMonitor

func AddProgramChangeMonitor(path string, fileChangeCb func(path string, mode filechangemonitor.FileChangeMode))

AddProgramChangeMonitor adds program change listener to monitor if the program binary

func NewProcCollector

func NewProcCollector(mgr *Manager) *procCollector

NewProcCollector returns new Collector exposing supervisord statistics.

func PathExpand

func PathExpand(path string) (string, error)

PathExpand replaces the ~ with user home directory

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manage all the process in the supervisor

func NewManager

func NewManager() *Manager

NewManager creates new Manager object

func (*Manager) Add

func (pm *Manager) Add(name string, proc *Process)

Add process to Manager object

func (*Manager) AsyncForEachProcess

func (pm *Manager) AsyncForEachProcess(procFunc func(p *Process), done chan *Process) int

AsyncForEachProcess handle each process in async mode Args: - procFunc, the function to handle the process - done, signal the process is completed Returns: number of total processes

func (*Manager) Clear

func (pm *Manager) Clear()

Clear all the processes from Manager object

func (*Manager) CreateProcess

func (pm *Manager) CreateProcess(supervisorID string, config *config.Entry) *Process

CreateProcess creates process (program or event listener) and adds to Manager object

func (*Manager) Find

func (pm *Manager) Find(name string) *Process

Find process by program name. Returns process or nil if process is not listed in Manager object

func (*Manager) FindMatch

func (pm *Manager) FindMatch(name string) []*Process

FindMatch lookup program with one of following format: - group:program - group:* - program

func (*Manager) ForEachProcess

func (pm *Manager) ForEachProcess(procFunc func(p *Process))

ForEachProcess process each process in sync mode

func (*Manager) Remove

func (pm *Manager) Remove(name string) *Process

Remove process from Manager object

Arguments: name - the name of program

Return the process or nil

func (*Manager) StartAutoStartPrograms

func (pm *Manager) StartAutoStartPrograms()

StartAutoStartPrograms starts all programs that set as should be autostarted

func (*Manager) StopAllProcesses

func (pm *Manager) StopAllProcesses()

StopAllProcesses stop all the processes listed in Manager object

type Process

type Process struct {
	StdoutLog logger.Logger
	StderrLog logger.Logger
	// contains filtered or unexported fields
}

Process the program process management data

func NewProcess

func NewProcess(supervisorID string, config *config.Entry) *Process

NewProcess creates new Process object

func (*Process) GetConfig

func (p *Process) GetConfig() *config.Entry

func (*Process) GetDescription

func (p *Process) GetDescription() string

GetDescription returns process status description

func (*Process) GetExitstatus

func (p *Process) GetExitstatus() int

GetExitstatus returns exit status of the process if the program exit

func (*Process) GetGroup

func (p *Process) GetGroup() string

GetGroup returns group the program belongs to

func (*Process) GetName

func (p *Process) GetName() string

GetName returns name of program or event listener

func (*Process) GetPid

func (p *Process) GetPid() int

GetPid returns pid of running process or 0 it is not in running status

func (*Process) GetPriority

func (p *Process) GetPriority() int

GetPriority returns program priority (as it set in config) with default value of 999

func (*Process) GetStartTime

func (p *Process) GetStartTime() time.Time

GetStartTime returns process start time

func (*Process) GetState

func (p *Process) GetState() State

GetState returns process state

func (*Process) GetStatus

func (p *Process) GetStatus() string

GetStatus returns status of program as a string

func (*Process) GetStderrLogfile

func (p *Process) GetStderrLogfile() string

GetStderrLogfile returns program stderr log filename

func (*Process) GetStdoutLogfile

func (p *Process) GetStdoutLogfile() string

GetStdoutLogfile returns program stdout log filename

func (*Process) GetStopTime

func (p *Process) GetStopTime() time.Time

GetStopTime returns process stop time

func (*Process) SendProcessStdin

func (p *Process) SendProcessStdin(chars string) error

SendProcessStdin sends data to process stdin

func (*Process) Signal

func (p *Process) Signal(sig os.Signal, sigChildren bool) error

Signal sends signal to the process

Args:

sig - the signal to the process
sigChildren - if true, sends the same signal to the process and its children

func (*Process) Start

func (p *Process) Start(wait bool)

Start process Args:

wait - true, wait the program started or failed

func (*Process) Stop

func (p *Process) Stop(wait bool)

Stop sends signal to process to make it quit

type State

type State int

State the state of process

func (State) String

func (p State) String() string

String convert State to human-readable string

Jump to

Keyboard shortcuts

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