Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ProgramGroup *ProcessGroup
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(configFile string) *Config

func (*Config) GetConfigFile

func (c *Config) GetConfigFile() string

func (*Config) GetConfigFileDir

func (c *Config) GetConfigFileDir() string

func (*Config) GetEntries

func (c *Config) GetEntries(filterFunc func(entry *ConfigEntry) bool) []*ConfigEntry

func (*Config) GetEventListeners

func (c *Config) GetEventListeners() []*ConfigEntry

func (*Config) GetGroupProgramNames

func (c *Config) GetGroupProgramNames(name string) []string

获取Group下的所有program的name

func (*Config) GetGroupPrograms

func (c *Config) GetGroupPrograms(name string) []*ConfigEntry

获取Group下的所有programs

func (*Config) GetGroups

func (c *Config) GetGroups() []*ConfigEntry

func (*Config) GetInetHttpServer

func (c *Config) GetInetHttpServer() (*ConfigEntry, bool)

Get the inet_http_server configuration section

func (*Config) GetProgram

func (c *Config) GetProgram(name string) *ConfigEntry

return the proram configure entry or nil 20190320: update时候,可能指定group,或者是program, 若program为numprocs类型的,则update 该program的group func (c *Config) GetProgram(name string) []*ConfigEntry {

c.lock.Lock()
ret := make([]*ConfigEntry, 0)
for _, entry := range c.entries {
	fmt.Println("GetProgram", "1:", entry.Name, "2:", entry.Group, "3:", entry.GetProgramName())
	if entry.IsProgram() && entry.Group == name {
		if entry.IsMultiIns() {
			c.lock.Unlock()
			return c.GetGroupPrograms(entry.Group)
		} else {
			c.lock.Unlock()
			return append(ret, entry)
		}
	}
}
c.lock.Unlock()
return ret

}

func (*Config) GetProgramNames

func (c *Config) GetProgramNames() []string

func (*Config) GetPrograms

func (c *Config) GetPrograms() []*ConfigEntry

func (*Config) GetSupervisorctl

func (c *Config) GetSupervisorctl() (*ConfigEntry, bool)

func (*Config) GetSupervisord

func (c *Config) GetSupervisord() (*ConfigEntry, bool)

get the supervisord section

func (*Config) GetUnixHttpServer

func (c *Config) GetUnixHttpServer() (*ConfigEntry, bool)

get the unix_http_server section

func (*Config) Load

func (c *Config) Load() ([]string, error)

return the loaded programs

func (*Config) LoadGroup

func (c *Config) LoadGroup(gName string) []string

重新update一个group时加载配置文件

func (*Config) MatchProgramName

func (c *Config) MatchProgramName(name string) []string

20190320 使用通配符匹配, 如groupA:*, 可以得到groupA下面所有的program名称

func (*Config) RemoveGroup

func (c *Config) RemoveGroup(groupName string)

func (*Config) RemoveProgram

func (c *Config) RemoveProgram(programName string)

func (*Config) String

func (c *Config) String() string

func (*Config) UpdateConfigEntry

func (c *Config) UpdateConfigEntry(name string) error

type ConfigEntry

type ConfigEntry struct {
	ConfigDir string
	Group     string
	Name      string
	// contains filtered or unexported fields
}

func NewConfigEntry

func NewConfigEntry(configDir string) *ConfigEntry

func (*ConfigEntry) Clone

func (c *ConfigEntry) Clone() ConfigEntry

func (*ConfigEntry) GetBool

func (c *ConfigEntry) GetBool(key string, defValue bool) bool

get value of key as bool

func (*ConfigEntry) GetBytes

func (c *ConfigEntry) GetBytes(key string, defValue int) int

get the value of key as the bytes setting.

logSize=1MB
logSize=1GB
logSize=1KB
logSize=1024

func (*ConfigEntry) GetEnv

func (c *ConfigEntry) GetEnv(key string) []string

GetEnv get the value of key as environment setting. An environment string example:

environment = A="env 1",B="this is a test"

func (*ConfigEntry) GetEventListenerName

func (c *ConfigEntry) GetEventListenerName() string

func (*ConfigEntry) GetGroupName

func (c *ConfigEntry) GetGroupName() string

get the group name if this entry is group

func (*ConfigEntry) GetInt

func (c *ConfigEntry) GetInt(key string, defValue int) int

get the value of the key as int

func (*ConfigEntry) GetProgramName

func (c *ConfigEntry) GetProgramName() string

func (*ConfigEntry) GetPrograms

func (c *ConfigEntry) GetPrograms() []string

get the programs from the group

func (*ConfigEntry) GetString

func (c *ConfigEntry) GetString(key string, defValue string) string

get the value of key as string

func (*ConfigEntry) GetStringArray

func (c *ConfigEntry) GetStringArray(key string, sep string) []string

func (*ConfigEntry) GetStringExpression

func (c *ConfigEntry) GetStringExpression(key string, defValue string) string

get the value of key as string and attempt to parse it with StringExpression

func (*ConfigEntry) HasParameter

func (c *ConfigEntry) HasParameter(key string) bool

check if has parameter

func (*ConfigEntry) IsEventListener

func (c *ConfigEntry) IsEventListener() bool

func (*ConfigEntry) IsGroup

func (c *ConfigEntry) IsGroup() bool

func (*ConfigEntry) IsMultiIns

func (c *ConfigEntry) IsMultiIns() bool

是否用到了numprocs参数

func (*ConfigEntry) IsProgram

func (c *ConfigEntry) IsProgram() bool

func (*ConfigEntry) IsSame

func (c *ConfigEntry) IsSame(entry ConfigEntry) bool

func (*ConfigEntry) String

func (c *ConfigEntry) String() string

dump the configuration as string

type ProcessGroup

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

func NewProcessGroup

func NewProcessGroup() *ProcessGroup

func (*ProcessGroup) Add

func (pg *ProcessGroup) Add(group string, procName string)

add a process to a group

func (*ProcessGroup) Clone

func (pg *ProcessGroup) Clone() *ProcessGroup

clone the process group

func (*ProcessGroup) ForEachProcess

func (pg *ProcessGroup) ForEachProcess(procFunc func(group string, procName string))

func (*ProcessGroup) GetAllGroup

func (pg *ProcessGroup) GetAllGroup() []string

get all the groups

func (*ProcessGroup) GetAllProcess

func (pg *ProcessGroup) GetAllProcess(group string) []string

get all the processes in a group

func (*ProcessGroup) GetGroup

func (pg *ProcessGroup) GetGroup(procName string, defGroup string) string

func (*ProcessGroup) GroupExists

func (pg *ProcessGroup) GroupExists(name string) bool

func (*ProcessGroup) InGroup

func (pg *ProcessGroup) InGroup(procName string, group string) bool

check if a process belongs to a group or not

func (*ProcessGroup) Remove

func (pg *ProcessGroup) Remove(procName string)

remove a process

func (*ProcessGroup) String

func (pg *ProcessGroup) String() string

func (*ProcessGroup) Sub

func (pg *ProcessGroup) Sub(other *ProcessGroup) (added, changed, removed, same []string)

type ProcessSorter

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

func NewProcessSorter

func NewProcessSorter() *ProcessSorter

func (*ProcessSorter) SortProgram

func (p *ProcessSorter) SortProgram(program_configs []*ConfigEntry) []*ConfigEntry

type ProgramByPriority

type ProgramByPriority []*ConfigEntry

func (ProgramByPriority) Len

func (p ProgramByPriority) Len() int

func (ProgramByPriority) Less

func (p ProgramByPriority) Less(i, j int) bool

func (ProgramByPriority) Swap

func (p ProgramByPriority) Swap(i, j int)

type StringExpression

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

func NewStringExpression

func NewStringExpression(envs ...string) *StringExpression

func (*StringExpression) Add

func (se *StringExpression) Add(key string, value string) *StringExpression

func (*StringExpression) Eval

func (se *StringExpression) Eval(s string) (string, error)