service

package
v0.0.0-...-be26699 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitSystemSystemd = "systemd"
	InitSystemUpstart = "upstart"
	InitSystemWindows = "windows"
)

These are the names of the init systems regognized by juju.

Variables

This section is empty.

Functions

func AgentConf

func AgentConf(info AgentInfo, renderer shell.Renderer) common.Conf

AgentConf returns the data that defines an init service config for the identified agent.

func ContainerAgentConf

func ContainerAgentConf(info AgentInfo, renderer shell.Renderer, containerType string) common.Conf

ContainerAgentConf returns the data that defines an init service config for the identified agent running in a container.

func DiscoverInitSystemScript

func DiscoverInitSystemScript() string

DiscoverInitSystemScript returns the shell script to use when discovering the local init system. The script is quite specific to bash, so it includes an explicit bash shbang.

func InstallAndStart

func InstallAndStart(svc ServiceActions) error

InstallAndStart installs the provided service and tries starting it. The first few Start failures are ignored.

func ListServices

func ListServices() ([]string, error)

ListServices lists all installed services on the running system

func ListServicesScript

func ListServicesScript() string

ListServicesScript returns the commands that should be run to get a list of service names on a host.

func Restart

func Restart(name string) error

Restart restarts the named service.

func ShutdownAfterConf

func ShutdownAfterConf(serviceName string) (common.Conf, error)

ShutdownAfterConf builds a service conf that will cause the host to shut down after the named service stops.

func VersionInitSystem

func VersionInitSystem(series string) (string, error)

VersionInitSystem returns an init system name based on the provided series. If one cannot be identified a NotFound error is returned.

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

func NewAgentInfo(kind AgentKind, id, dataDir, logDir string) AgentInfo

NewAgentInfo composes a new AgentInfo for the given essentials.

func NewMachineAgentInfo

func NewMachineAgentInfo(id, dataDir, logDir string) AgentInfo

NewMachineAgentInfo returns a new AgentInfo for a machine agent.

func NewUnitAgentInfo

func NewUnitAgentInfo(id, dataDir, logDir string) AgentInfo

NewUnitAgentInfo returns a new AgentInfo for a unit agent.

func (AgentInfo) ToolsDir

func (ai AgentInfo) ToolsDir(renderer shell.Renderer) string

ToolsDir returns the path to the agent's tools dir.

type AgentKind

type AgentKind string

AgentKind identifies the kind of agent.

const (
	AgentKindMachine AgentKind = "machine"
	AgentKindUnit    AgentKind = "unit"
)

These are the agent kinds in juju.

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)
}

Service represents a service in the init system running on a host.

func DiscoverService

func DiscoverService(name string, conf common.Conf) (Service, error)

DiscoverService returns an interface to a service appropriate for the current system

func NewService

func NewService(name string, conf common.Conf, series string) (Service, error)

NewService returns a new Service based on the provided info.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL