Documentation ¶
Index ¶
- Constants
- func Start(s *state.State, services []string) (*state.TaskSet, error)
- func Stop(s *state.State, services []string) (*state.TaskSet, error)
- func StopRunning(s *state.State, m *ServiceManager) (*state.TaskSet, error)
- type LabelExists
- type LogManager
- type PlanFunc
- type Restarter
- type ServiceInfo
- type ServiceManager
- func (m *ServiceManager) AppendLayer(layer *plan.Layer) error
- func (m *ServiceManager) CheckFailed(name string)
- func (m *ServiceManager) CombineLayer(layer *plan.Layer) error
- func (m *ServiceManager) DefaultServiceNames() ([]string, error)
- func (m *ServiceManager) Ensure() error
- func (m *ServiceManager) NotifyPlanChanged(f PlanFunc)
- func (m *ServiceManager) Plan() (*plan.Plan, error)
- func (m *ServiceManager) Replan() ([]string, []string, error)
- func (m *ServiceManager) SendSignal(services []string, signal string) error
- func (m *ServiceManager) ServiceLogs(services []string, last int) (map[string]servicelog.Iterator, error)
- func (m *ServiceManager) Services(names []string) ([]*ServiceInfo, error)
- func (m *ServiceManager) SetServiceArgs(serviceArgs map[string][]string) error
- func (m *ServiceManager) StartOrder(services []string) ([]string, error)
- func (m *ServiceManager) Stop()
- func (m *ServiceManager) StopOrder(services []string) ([]string, error)
- func (m *ServiceManager) StopTimeout() time.Duration
- type ServiceRequest
- type ServiceStartup
- type ServiceStatus
Constants ¶
const ( StartupEnabled = "enabled" StartupDisabled = "disabled" )
Variables ¶
This section is empty.
Functions ¶
func StopRunning ¶
StopRunning creates and returns a task set for stopping all running services. It returns a nil *TaskSet if there are no services to stop.
Types ¶
type LabelExists ¶
type LabelExists struct {
Label string
}
LabelExists is the error returned by AppendLayer when a layer with that label already exists.
func (*LabelExists) Error ¶
func (e *LabelExists) Error() string
type LogManager ¶
type LogManager interface {
ServiceStarted(service *plan.Service, logs *servicelog.RingBuffer)
}
type Restarter ¶
type Restarter interface {
HandleRestart(t restart.RestartType)
}
type ServiceInfo ¶
type ServiceInfo struct { Name string Startup ServiceStartup Current ServiceStatus CurrentSince time.Time }
type ServiceManager ¶
type ServiceManager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(s *state.State, runner *state.TaskRunner, pebbleDir string, serviceOutput io.Writer, restarter Restarter, logMgr LogManager) (*ServiceManager, error)
func (*ServiceManager) AppendLayer ¶
func (m *ServiceManager) AppendLayer(layer *plan.Layer) error
AppendLayer appends the given layer to the plan's layers and updates the layer.Order field to the new order. If a layer with layer.Label already exists, return an error of type *LabelExists.
func (*ServiceManager) CheckFailed ¶
func (m *ServiceManager) CheckFailed(name string)
CheckFailed response to a health check failure. If the given check name is in the on-check-failure map for a service, tell the service to perform the configured action (for example, "restart").
func (*ServiceManager) CombineLayer ¶
func (m *ServiceManager) CombineLayer(layer *plan.Layer) error
CombineLayer combines the given layer with an existing layer that has the same label. If no existing layer has the label, append a new one. In either case, update the layer.Order field to the new order.
func (*ServiceManager) DefaultServiceNames ¶
func (m *ServiceManager) DefaultServiceNames() ([]string, error)
DefaultServiceNames returns the name of the services set to start by default.
func (*ServiceManager) Ensure ¶
func (m *ServiceManager) Ensure() error
Ensure implements StateManager.Ensure.
func (*ServiceManager) NotifyPlanChanged ¶
func (m *ServiceManager) NotifyPlanChanged(f PlanFunc)
NotifyPlanChanged adds f to the list of functions that are called whenever the plan is updated.
func (*ServiceManager) Plan ¶
func (m *ServiceManager) Plan() (*plan.Plan, error)
Plan returns the configuration plan.
func (*ServiceManager) Replan ¶
func (m *ServiceManager) Replan() ([]string, []string, error)
Replan returns a list of services to stop and services to start because their plans had changed between when they started and this call.
func (*ServiceManager) SendSignal ¶
func (m *ServiceManager) SendSignal(services []string, signal string) error
func (*ServiceManager) ServiceLogs ¶
func (m *ServiceManager) ServiceLogs(services []string, last int) (map[string]servicelog.Iterator, error)
ServiceLogs returns iterators to the provided services. If last is negative, return tail iterators; if last is zero or positive, return head iterators going back last elements. Each iterator must be closed via the Close method.
func (*ServiceManager) Services ¶
func (m *ServiceManager) Services(names []string) ([]*ServiceInfo, error)
Services returns the list of configured services and their status, sorted by service name. Filter by the specified service names if provided.
func (*ServiceManager) SetServiceArgs ¶
func (m *ServiceManager) SetServiceArgs(serviceArgs map[string][]string) error
SetServiceArgs sets the service arguments provided by "pebble run --args" to their respective services. It adds a new layer in the plan, the layer consisting of services with commands having their arguments changed.
func (*ServiceManager) StartOrder ¶
func (m *ServiceManager) StartOrder(services []string) ([]string, error)
StartOrder returns the provided services, together with any required dependencies, in the proper order for starting them all up.
func (*ServiceManager) Stop ¶
func (m *ServiceManager) Stop()
Stop implements overlord.StateStopper and stops background functions.
func (*ServiceManager) StopOrder ¶
func (m *ServiceManager) StopOrder(services []string) ([]string, error)
StopOrder returns the provided services, together with any dependants, in the proper order for stopping them all.
func (*ServiceManager) StopTimeout ¶
func (m *ServiceManager) StopTimeout() time.Duration
StopTimeout returns the worst case duration that will have to be waited for to have all services in this manager stopped.
type ServiceRequest ¶
type ServiceRequest struct {
Name string
}
ServiceRequest holds the details required to perform service tasks.
func TaskServiceRequest ¶
func TaskServiceRequest(task *state.Task) (*ServiceRequest, error)
TaskServiceRequest extracts the *ServiceRequest that was associated with the provided task when it was created, reflecting details of the operation requested.
type ServiceStartup ¶
type ServiceStartup string
type ServiceStatus ¶
type ServiceStatus string
const ( StatusActive ServiceStatus = "active" StatusBackoff ServiceStatus = "backoff" StatusError ServiceStatus = "error" StatusInactive ServiceStatus = "inactive" )