Documentation
¶
Index ¶
- Constants
- Variables
- func AgentConf(info AgentInfo, renderer shell.Renderer) common.Conf
- func ContainerAgentConf(info AgentInfo, renderer shell.Renderer, containerType string) common.Conf
- func FindAgents(dataDir string) (string, []string, []string, error)
- func InstallAndStart(svc ServiceActions) error
- func ListServicesScript() string
- func Restart(name string) error
- func ShutdownAfterConf(serviceName string) (common.Conf, error)
- type AgentInfo
- type AgentKind
- type RestartableService
- type Service
- type ServiceActions
- type SystemdServiceManager
Constants ¶
const (
InitSystemSystemd = "systemd"
)
Variables ¶
var ListServices = func() ([]string, error) { services, err := systemd.ListServices() return services, errors.Annotatef(err, "failed to list systemd services") }
ListServices lists all installed services on the running system
var NewService = func(name string, conf common.Conf) (Service, error) { if name == "" { return nil, errors.New("missing name") } return systemd.NewServiceWithDefaults(name, conf) }
NewService returns a new Service based on the provided info.
Functions ¶
func AgentConf ¶
AgentConf returns the data that defines an init service config for the identified agent.
func ContainerAgentConf ¶
ContainerAgentConf returns the data that defines an init service config for the identified agent running in a container.
func FindAgents ¶
FindAgents finds all the agents available on the machine.
func InstallAndStart ¶
func InstallAndStart(svc ServiceActions) error
InstallAndStart installs the provided service and tries starting it. The first few Start failures are ignored.
func ListServicesScript ¶
func ListServicesScript() string
ListServicesScript returns the commands that should be run to get a list of service names on a host.
Types ¶
type AgentInfo ¶
type AgentInfo struct {
// ID is the string that identifies the agent uniquely within
// a juju environment.
ID string
// Kind is the kind of agent.
Kind AgentKind
// DataDir is the path to the agent's data dir.
DataDir string
// LogDir is the path to the agent's log dir.
LogDir string
// contains filtered or unexported fields
}
AgentInfo holds commonly used information about a juju agent.
func NewAgentInfo ¶
NewAgentInfo composes a new AgentInfo for the given essentials.
func NewMachineAgentInfo ¶
NewMachineAgentInfo returns a new AgentInfo for a machine agent.
func NewUnitAgentInfo ¶
NewUnitAgentInfo returns a new AgentInfo for a unit agent.
type RestartableService ¶
type RestartableService interface {
// Restart restarts the service.
Restart() error
}
RestartableService is a service that directly supports restarting.
type Service ¶
type Service interface {
ServiceActions
// Name returns the service's name.
Name() string
// Conf returns the service's conf data.
Conf() common.Conf
// Running returns a boolean value that denotes
// whether or not the service is running.
Running() (bool, error)
// Exists returns whether the service configuration exists in the
// init directory with the same content that this Service would have
// if installed.
Exists() (bool, error)
// Installed will return a boolean value that denotes
// whether or not the service is installed.
Installed() (bool, error)
// InstallCommands returns the list of commands to run on a
// (remote) host to install the service.
InstallCommands() ([]string, error)
// StartCommands returns the list of commands to run on a
// (remote) host to start the service.
StartCommands() ([]string, error)
// WriteService writes the service conf data. If the service is
// running, WriteService adds links to allow for manual and automatic
// starting of the service.
WriteService() error
}
Service represents a service in the init system running on a host.
func NewServiceReference ¶
NewServiceReference returns a reference to an existing Service and can be used to start/stop the service.
type ServiceActions ¶
type ServiceActions interface {
// Start will try to start the service.
Start() error
// Stop will try to stop the service.
Stop() error
// Install installs a service.
Install() error
// Remove will remove the service.
Remove() error
}
ServiceActions represents the actions that may be requested for an init system service.
type SystemdServiceManager ¶
type SystemdServiceManager interface {
// FindAgents finds all the agents available in the machine.
FindAgents(dataDir string) (string, []string, []string, error)
// WriteSystemdAgent creates systemd files and create symlinks for the
// machine passed in the standard filepath.
WriteSystemdAgent(
machineAgent string, dataDir, symLinkSystemdMultiUserDir string,
) error
//CreateAgentConf creates the configfile for specified agent running on a
// host with specified series.
CreateAgentConf(agentName string, dataDir string) (common.Conf, error)
// WriteServiceFile writes the service file for machine agent in the
// /etc/systemd/system path.
WriteServiceFile() error
}
func NewServiceManager ¶
func NewServiceManager( isRunning func() bool, newService func(string, common.Conf) (Service, error), ) SystemdServiceManager
NewServiceManager allows creation of a new SystemdServiceManager from custom dependencies.
func NewServiceManagerWithDefaults ¶
func NewServiceManagerWithDefaults() SystemdServiceManager
NewServiceManagerWithDefaults returns a SystemdServiceManager created with sensible defaults.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
pebble
|
|
|
identity
Package identity defines the various types to work with the Pebble identities file.
|
Package identity defines the various types to work with the Pebble identities file. |
|
plan
Package plan defines the various types to work with the Pebble plan and layers.
|
Package plan defines the various types to work with the Pebble plan and layers. |
|
Package snap manages installing and running snaps.
|
Package snap manages installing and running snaps. |