process

package module
v0.0.0-...-7111dfa Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 24 Imported by: 0

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 add a program change listener to monitor if any one of its configuration files is changed

func AddProgramChangeMonitor

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

AddProgramChangeMonitor add a program change listener to monitor if the program binary

func NewProcCollector

func NewProcCollector(mgr *Manager) *procCollector

NewProcCollector returns a new Collector exposing supervisord statistics.

func PathExpand

func PathExpand(path string) (string, error)

PathExpand replace 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 create a new Manager object

func (*Manager) Add

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

Add add the process to this process manager

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 clear all the processes

func (*Manager) CreateProcess

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

CreateProcess create a process (program or event listener) and add to this manager

func (*Manager) Find

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

Find find process by program name return process if found or nil if not found

func (*Manager) FindMatch

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

FindMatch find the 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 remove the process from the manager

Arguments: name - the name of program

Return the process or nil

func (*Manager) StartAutoStartPrograms

func (pm *Manager) StartAutoStartPrograms()

StartAutoStartPrograms start all the program if its autostart is true

func (*Manager) StopAllProcesses

func (pm *Manager) StopAllProcesses()

StopAllProcesses stop all the processes managed by this manager

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 create a new Process

func (*Process) GetArgs

func (p *Process) GetArgs() []string

func (*Process) GetDescription

func (p *Process) GetDescription() string

GetDescription get the process status description

func (*Process) GetExitstatus

func (p *Process) GetExitstatus() int

GetExitstatus get the exit status of the process if the program exit

func (*Process) GetGroup

func (p *Process) GetGroup() string

GetGroup which group the program belongs to

func (*Process) GetName

func (p *Process) GetName() string

GetName get the name of program or event listener

func (*Process) GetPid

func (p *Process) GetPid() int

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

func (*Process) GetPriority

func (p *Process) GetPriority() int

GetPriority get the program priority

func (*Process) GetStartTime

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

GetStartTime get the process start time

func (*Process) GetState

func (p *Process) GetState() State

GetState Get the process state

func (*Process) GetStatus

func (p *Process) GetStatus() string

GetStatus get the status of program in string

func (*Process) GetStderrLogfile

func (p *Process) GetStderrLogfile() string

GetStderrLogfile get the program stderr log file

func (*Process) GetStdoutLogfile

func (p *Process) GetStdoutLogfile() string

GetStdoutLogfile get the program stdout log file

func (*Process) GetStopTime

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

GetStopTime get the process stop time

func (*Process) SendProcessStdin

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

SendProcessStdin send data to process stdin

func (*Process) SetupArgs

func (p *Process) SetupArgs(args string)

func (*Process) Signal

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

Signal send signal to the process

Args:

sig - the signal to the process
sigChildren - true: send the signal to the process and its children proess

func (*Process) Start

func (p *Process) Start(wait bool)

Start start the process Args:

wait - true, wait the program started or failed

func (*Process) Stop

func (p *Process) Stop(wait bool)

Stop send signal to process to stop it

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
⌂ 换网址