Documentation
¶
Index ¶
- func AddConfigChangeMonitor(path, filePattern string, ...)
- func AddProgramChangeMonitor(path string, ...)
- func SetShellArgs(s []string)
- type Manager
- func (pm *Manager) Add(name string, proc *Process)
- func (pm *Manager) AsyncForEachProcess(procFunc func(p *Process), done chan *Process) int
- func (pm *Manager) Clear()
- func (pm *Manager) CreateOrUpdateProcess(supervisorID string, after *config.Process) *Process
- func (pm *Manager) Find(name string) *Process
- func (pm *Manager) FindMatch(name string) []*Process
- func (pm *Manager) FindMatchWithLabels(name string, labels map[string]string) []*Process
- func (pm *Manager) ForEachProcess(procFunc func(p *Process))
- func (pm *Manager) RemoveProcess(name string) *Process
- func (pm *Manager) StartAutoStartPrograms()
- func (pm *Manager) StopAllProcesses()
- type Process
- func (p *Process) Config() *config.Process
- func (p *Process) Description() string
- func (p *Process) Destroy(wait bool)
- func (p *Process) ExitStatus() int
- func (p *Process) GetStatus() string
- func (p *Process) Group() string
- func (p *Process) MatchLabels(labels map[string]string) bool
- func (p *Process) Name() string
- func (p *Process) Pid() int
- func (p *Process) SendProcessStdin(chars string) error
- func (p *Process) Signal(sig os.Signal, sigChildren bool) error
- func (p *Process) Start(wait bool)
- func (p *Process) StartTime() time.Time
- func (p *Process) State() State
- func (p *Process) StderrLogfile() string
- func (p *Process) StdoutLogfile() string
- func (p *Process) Stop(wait bool)
- func (p *Process) StopTime() time.Time
- func (p *Process) UpdateConfig(config *config.Process)
- type ResourceUsage
- type RingBuffer
- type StatError
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigChangeMonitor ¶
func AddConfigChangeMonitor(path, 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 SetShellArgs ¶
func SetShellArgs(s []string)
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manage all the process in the supervisor
func (*Manager) AsyncForEachProcess ¶
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) CreateOrUpdateProcess ¶
CreateOrUpdateProcess creates a new process and adds it to the manager or updates an existing process.
func (*Manager) Find ¶
Find find process by program name return process if found or nil if not found
func (*Manager) FindMatch ¶
FindMatch find the program with one of following format: - group.program - group.* - program
func (*Manager) FindMatchWithLabels ¶
FindMatchWithLabels matches Processes by name and labels.
func (*Manager) ForEachProcess ¶
ForEachProcess process each process in sync mode
func (*Manager) RemoveProcess ¶
RemoveProcess remove the process from the manager and stops it, if it was running. Returns the removed process.
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.CompositeLogger StderrLog *logger.CompositeLogger StdoutBacklog *RingBuffer StderrBacklog *RingBuffer // contains filtered or unexported fields }
Process the program process management data
func NewProcess ¶
NewProcess create a new Process
func (*Process) Description ¶
Description get the process status description
func (*Process) ExitStatus ¶
GetExitStatus get the exit status of the process if the program exit
func (*Process) MatchLabels ¶
MatchLabels sees if a Process's label-set matches some search set.
func (*Process) SendProcessStdin ¶
SendProcessStdin send data to process stdin
func (*Process) Signal ¶
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 ¶
Start start the process Args:
wait - true, wait the program started or failed
func (*Process) StderrLogfile ¶
GetStderrLogfile get the program stderr log file
func (*Process) StdoutLogfile ¶
GetStdoutLogfile get the program stdout log file
func (*Process) UpdateConfig ¶
type ResourceUsage ¶
ResourceUsage describes the system resource usage of a process.
func Stat ¶
func Stat(pid int) (*ResourceUsage, error)
Stat gets the resource usage of a pid using `ps`.
func (ResourceUsage) HumanResident ¶
func (r ResourceUsage) HumanResident() string
HumanResident returns a human readable version of the memory usage.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a ring-buffer.
func NewRingBuffer ¶
func NewRingBuffer(maxSize int) *RingBuffer
NewRingBuffer creates a new RingBuffer with the given maximum size in bytes.
func (*RingBuffer) Bytes ¶
func (l *RingBuffer) Bytes() (int64, []byte)
Bytes returns a byte slice containing all data written to the buffer and the number of bytes before it that have been discarded because of the buffer's size limit.
We trim the output to the first newline character (if we can find one) in order to keep the output looking nice.
type State ¶
type State int
State the state of process
const ( // Stopped the stopped state Stopped State = 0 // Starting the starting state Starting State = 10 // Running the running state Running State = 20 // Backoff the backoff state Backoff State = 30 // Stopping the stopping state Stopping State = 40 // Exited the Exited state Exited State = 100 // Fatal the Fatal state Fatal State = 200 // Unknown the unknown state Unknown State = 1000 )