Documentation
¶
Index ¶
- func CountServices(sgs []ServiceOrGroup) int
- func DoForServices(sgs []ServiceOrGroup, task tracker.Task, ...) error
- type ContextOverride
- type LaunchChecks
- type OperationConfig
- type ServiceConfig
- func (c *ServiceConfig) GetDescription() string
- func (c *ServiceConfig) GetName() string
- func (c *ServiceConfig) GetPid(pidFile string) (int, error)
- func (c *ServiceConfig) GetPidPathLegacy(pidDir string) string
- func (c *ServiceConfig) GetRunLog(logDir string) string
- func (c *ServiceConfig) GetStateBase(stateDir string) string
- func (c *ServiceConfig) GetStatePath(stateDir string) string
- func (c *ServiceConfig) IdentifyingFilename() string
- func (c *ServiceConfig) IsSudo(cfg OperationConfig) bool
- func (c *ServiceConfig) Matches(name string) bool
- func (c *ServiceConfig) MatchesPlatform() bool
- func (c *ServiceConfig) SetWatch(watch ServiceWatch) error
- func (c *ServiceConfig) UnmarshalJSON(data []byte) error
- func (c *ServiceConfig) Watch() ([]ServiceWatch, error)
- type ServiceConfigCommands
- type ServiceConfigProperties
- type ServiceGroupConfig
- func (c *ServiceGroupConfig) Children() []ServiceOrGroup
- func (c *ServiceGroupConfig) GetDescription() string
- func (c *ServiceGroupConfig) GetName() string
- func (c *ServiceGroupConfig) IsSudo(cfg OperationConfig) bool
- func (c *ServiceGroupConfig) Matches(name string) bool
- func (c *ServiceGroupConfig) Watch() ([]ServiceWatch, error)
- type ServiceOrGroup
- type ServiceWatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountServices ¶
func CountServices(sgs []ServiceOrGroup) int
CountServices returns the total number of services in the slice of services and groups.
func DoForServices ¶ added in v1.8.8
func DoForServices(sgs []ServiceOrGroup, task tracker.Task, f func(service *ServiceConfig, overrides ContextOverride, task tracker.Task) error) error
DoForServices performs a taks for a set of services
Types ¶
type ContextOverride ¶
type ContextOverride struct {
// Overrides to environment variables
Env []string
}
ContextOverride defines overrides for service configuration caused by commandline flags or group configuration.
func (ContextOverride) Merge ¶
func (c ContextOverride) Merge(m ContextOverride) ContextOverride
type LaunchChecks ¶
type LaunchChecks struct {
// A string to look for in the service's logs that indicates it has completed startup.
LogText string `json:"log_text,omitempty"`
// One or more specific ports that are expected to be opened when this service starts.
Ports []int `json:"ports,omitempty"`
// Wait for a specified amount of time (in ms) before calling the service started if still running.
Wait int64 `json:"wait,omitempty"`
}
LaunchChecks defines the mechanism for testing whether a service has started successfully
type OperationConfig ¶
type OperationConfig struct {
WorkingDir string
EdwardExecutable string // Path to the edward executable for launching runners
Exclusions []string // Names of services/groups to be excluded from this operation
NoWatch bool
SkipBuild bool
Tags []string // Tags to pass to `edward run`
LogFile string
}
OperationConfig provides additional configuration for an operation on a service or group
func (*OperationConfig) IsExcluded ¶
func (o *OperationConfig) IsExcluded(sg ServiceOrGroup) bool
IsExcluded returns true if the given service/group is excluded by this OperationConfig. No operations should be performed on excluded services.
type ServiceConfig ¶
type ServiceConfig struct {
// Service name, used to identify in commands
Name string `json:"name"`
// Alternative names for this service
Aliases []string `json:"aliases,omitempty"`
// Service description
Description string `json:"description,omitempty"`
// Optional path to service. If nil, uses cwd
Path *string `json:"path,omitempty"`
// Does this service require sudo privileges?
RequiresSudo bool `json:"requiresSudo,omitempty"`
// Commands for managing the service
Commands ServiceConfigCommands `json:"commands"`
// Checks to perform to ensure that a service has started correctly
LaunchChecks *LaunchChecks `json:"launch_checks,omitempty"`
// Env holds environment variables for a service, for example: GOPATH=~/gocode/
// These will be added to the vars in the environment under which the Edward command was run
Env []string `json:"env,omitempty"`
Platform string `json:"platform,omitempty"`
// Path to watch for updates, relative to config file. If specified, will enable hot reloading.
WatchJSON json.RawMessage `json:"watch,omitempty"`
// Action for warming up this service
Warmup *warmup.Warmup `json:"warmup,omitempty"`
// Path to config file from which this service was loaded
// This may be the file that imported the config containing the service definition.
ConfigFile string `json:"-"`
// Logger for actions on this service
Logger common.Logger `json:"-"`
// contains filtered or unexported fields
}
ServiceConfig represents a service that can be managed by Edward
func Services ¶ added in v1.8.8
func Services(sgs []ServiceOrGroup) []*ServiceConfig
Services returns a slice of services from a slice of services or groups.
func (*ServiceConfig) GetDescription ¶
func (c *ServiceConfig) GetDescription() string
GetDescription returns the description for this service
func (*ServiceConfig) GetName ¶
func (c *ServiceConfig) GetName() string
GetName returns the name for this service
func (*ServiceConfig) GetPid ¶ added in v1.8.8
func (c *ServiceConfig) GetPid(pidFile string) (int, error)
func (*ServiceConfig) GetPidPathLegacy ¶
func (c *ServiceConfig) GetPidPathLegacy(pidDir string) string
func (*ServiceConfig) GetRunLog ¶
func (c *ServiceConfig) GetRunLog(logDir string) string
GetRunLog returns the path to the run log for this service
func (*ServiceConfig) GetStateBase ¶ added in v1.8.8
func (c *ServiceConfig) GetStateBase(stateDir string) string
func (*ServiceConfig) GetStatePath ¶ added in v1.8.8
func (c *ServiceConfig) GetStatePath(stateDir string) string
func (*ServiceConfig) IdentifyingFilename ¶ added in v1.8.8
func (c *ServiceConfig) IdentifyingFilename() string
IdentifyingFilename returns a filename that can be used to identify this service uniquely among all services that may be configured on a machine. The filename will be based on the service name and the path to its Edward config. It does not include an extension.
func (*ServiceConfig) IsSudo ¶
func (c *ServiceConfig) IsSudo(cfg OperationConfig) bool
IsSudo returns true if this service requires sudo to run. If this service is excluded by cfg, then will always return false.
func (*ServiceConfig) Matches ¶
func (c *ServiceConfig) Matches(name string) bool
Matches returns true if the service name or an alias matches the provided name.
func (*ServiceConfig) MatchesPlatform ¶
func (c *ServiceConfig) MatchesPlatform() bool
MatchesPlatform determines whether or not this service can be run on the current OS
func (*ServiceConfig) SetWatch ¶
func (c *ServiceConfig) SetWatch(watch ServiceWatch) error
SetWatch sets the watch configuration for this service
func (*ServiceConfig) UnmarshalJSON ¶
func (c *ServiceConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON provides additional handling when unmarshaling a service from config. Currently, this handles legacy fields and fields with multiple possible types.
func (*ServiceConfig) Watch ¶
func (c *ServiceConfig) Watch() ([]ServiceWatch, error)
Watch returns the watch configuration for this service
type ServiceConfigCommands ¶
type ServiceConfigCommands struct {
// Command to build
Build string `json:"build,omitempty"`
// Command to launch
Launch string `json:"launch,omitempty"`
// Optional command to stop
Stop string `json:"stop,omitempty"`
}
ServiceConfigCommands define the commands for building, launching and stopping a service All commands are optional
type ServiceConfigProperties ¶
type ServiceConfigProperties struct {
// Regex to detect a line indicating the service has started successfully
Started string `json:"started,omitempty"`
// Custom properties, mapping a property name to a regex
Custom map[string]string `json:"-"`
}
ServiceConfigProperties provides a set of regexes to detect properties of a service Deprecated: This has been dropped in favour of LaunchChecks
type ServiceGroupConfig ¶
type ServiceGroupConfig struct {
// A name for this group, used to identify it in commands
Name string
// Alternative names for this group
Aliases []string
// A description
Description string
// Full services contained within this group
Services []*ServiceConfig
// Groups on which this group depends
Groups []*ServiceGroupConfig
// Launch order for children
ChildOrder []string
// Environment variables to be passed to all child services
Env []string
Logger common.Logger
}
ServiceGroupConfig is a group of services that can be managed together
func (*ServiceGroupConfig) Children ¶ added in v1.8.8
func (c *ServiceGroupConfig) Children() []ServiceOrGroup
Children returns a slice of all children of this group in the configured order
func (*ServiceGroupConfig) GetDescription ¶
func (c *ServiceGroupConfig) GetDescription() string
GetDescription returns the description for this group
func (*ServiceGroupConfig) GetName ¶
func (c *ServiceGroupConfig) GetName() string
GetName returns the name for this group
func (*ServiceGroupConfig) IsSudo ¶
func (c *ServiceGroupConfig) IsSudo(cfg OperationConfig) bool
IsSudo returns true if any of the services in this group require sudo to run
func (*ServiceGroupConfig) Matches ¶
func (c *ServiceGroupConfig) Matches(name string) bool
Matches returns true if the group name or an alias matches the provided name.
func (*ServiceGroupConfig) Watch ¶
func (c *ServiceGroupConfig) Watch() ([]ServiceWatch, error)
Watch returns all service watches configured for this group
type ServiceOrGroup ¶
type ServiceOrGroup interface {
GetName() string
GetDescription() string
IsSudo(cfg OperationConfig) bool
Watch() ([]ServiceWatch, error)
}
ServiceOrGroup provides a common interface to services and groups
type ServiceWatch ¶
type ServiceWatch struct {
Service *ServiceConfig `json:"-"`
IncludedPaths []string `json:"include,omitempty"`
ExcludedPaths []string `json:"exclude,omitempty"`
}
ServiceWatch defines a set of directories to be watched for changes to a service's source.