Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of the supervisor plugin
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Bond supervisor process to given set of CPUs. Plugin uses taskset to assign process // to CPUs and uses the same hexadecimal format. Invalid value prints error but does // not terminate the process. // It is recommended to use this option only for testing, operating system CPU schedulers // are in general more superior in managing CPU cycles. SvCPUAffinityMask string `json:"sv-cpu-affinity-mask"` // A list of programs started by the supervisor. Programs []Program // A list of hooks managed by supervisor plugin. Hooks are additional commands or scripts // called after some specific process events. Hooks []Hook }
Config represents supervision setup where programs will be started at the beginning and hooks are special commands which are executed when certain event related to one of the processes occurs
func NewEmptyConfig ¶
func NewEmptyConfig() *Config
NewEmptyConfig prepares empty configuration ready to populate from the file
type Deps ¶
type Deps struct { infra.PluginDeps PM pm.ProcessManager }
Deps are supervisor plugin dependencies
type EventType ¶
type EventType int
EventType represents type of the given event
const ( // ProcessStatus represents events about process status ProcessStatus EventType = 1 )
type Hook ¶
type Hook struct { // Command which will be executed Cmd string `json:"cmd"` // Command arguments CmdArgs []string `json:"cmd-args"` }
Hook is a procedure called when a program gets into certain state.
type Option ¶
type Option func(*Plugin)
Option is a function that can be used in the NewPlugin to customize plugin options
type Plugin ¶
type Plugin struct { Deps // contains filtered or unexported fields }
Plugin is a supervisor plugin representation
func (*Plugin) GetProgramByName ¶
func (p *Plugin) GetProgramByName(reqName string) pm.ProcessInstance
GetProgramByName returns the process instance of a given program
func (*Plugin) GetProgramNames ¶
GetProgramNames returns names of all running process instances
type Program ¶
type Program struct { // Name is an optional parameter, if not set it will be derived from the executable Name string `json:"name"` // ExecutablePath is a path to the binary file, required field ExecutablePath string `json:"executable-path"` // ExecutableArgs is a list of arguments passed to the binary ExecutableArgs []string `json:"executable-args"` // LogfilePath is defined when the log output should be written to the file. No file // is written if not set LogfilePath string `json:"logfile-path"` // Number of automatic restarts. Note that any termination hooks are executed also // when the program is restarted since the operating system sends events in order // termination -> starting -> sleeping/idle Restarts int `json:"restarts"` // Bond process to given set of CPUs. Plugin uses taskset to assign process to CPUs // and uses the same hexadecimal format. Invalid value prints error message but does // not terminate the process. // Note: use only when you know what you are doing, do not try to outsmart OS CPU // scheduling. If a program has its own config file to manage CPUs, prioritize it. // Keep in mind that incorrect use may slow down certain applications or that the // application may contain its own CPU manager which overrides this value. // Warning: Locking process to CPU does NOT keep other processes off that CPU. CPUAffinityMask string `json:"cpu-affinity-mask"` // This field can postpone CPU affinity setup for given time. Some processes may // manipulate CPU scheduling during startup, this option allows to "bypass" it, // waiting until the process is fully loaded and then lock it. CPUAffinitySetupDelay time.Duration `json:"cpu-affinity-setup-delay"` }
Program is a single program representation
type Supervisor ¶
type Supervisor interface { // GetProgramNames returns names of all running program instances GetProgramNames() []string // GetProgramByName returns the process instance of a given program GetProgramByName(name string) pm.ProcessInstance }
Supervisor is a simple interface to gather information about running programs
type SvLogger ¶
type SvLogger struct {
// contains filtered or unexported fields
}
SvLogger is a logger object compatible with the process manager. It uses writer to print log to stdout or a file
func NewSvLogger ¶
NewSvLogger prepares new supervisor logger for given process.