instance

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 24 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAllStatusesForService

func DeleteAllStatusesForService(service *services.ServiceConfig, baseDir string) error

func DeleteStatusForService

func DeleteStatusForService(service *services.ServiceConfig, instanceId, baseDir string) error

func HasRunning

func HasRunning(dirConfig *home.EdwardConfiguration, service *services.ServiceConfig) (bool, error)

HasRunning returns true iff the specified service has a currently running instance

func InterruptGroup

func InterruptGroup(cfg services.OperationConfig, pgid int, service *services.ServiceConfig) error

InterruptGroup sends an interrupt signal to a process group. Will use sudo if required by this service.

func KillGroup

func KillGroup(cfg services.OperationConfig, pgid int, service *services.ServiceConfig) error

KillGroup sends a kill signal to a process group. Will use sudo priviledges if required by this service.

func Launch

Launch launches this service

func LoadRunningServices

func LoadRunningServices(stateDir string) ([]services.ServiceOrGroup, error)

func LoadStatusForService

func LoadStatusForService(service *services.ServiceConfig, baseDir string) (map[string]Status, error)

func SaveStatusForService

func SaveStatusForService(service *services.ServiceConfig, instanceId string, status Status, baseDir string) error

func Stop

Stop stops this service

func WaitUntilRunning

func WaitUntilRunning(dirCfg *home.EdwardConfiguration, cmd *exec.Cmd, service *services.ServiceConfig) error

WaitUntilRunning will block the specified service until it enters the running state

Types

type Instance

type Instance struct {
	// Parent service config
	Service *services.ServiceConfig `json:"service"`
	// Pid of currently running instance
	Pid int `json:"pid"`
	// Config file from which this instance was launched
	ConfigFile string `json:"configFile"`
	// The edward version under which this instance was launched
	EdwardVersion string `json:"edwardVersion"`
	// Overrides applied by the group under which this service was started
	Overrides services.ContextOverride `json:"overrides,omitempty"`
	// Identifier for this instance of the service
	InstanceId string
	// contains filtered or unexported fields
}

Instance provides state and functions for managing a service

func Load

func Load(dirConfig *home.EdwardConfiguration, service *services.ServiceConfig, overrides services.ContextOverride) (command *Instance, err error)

Load loads an instance to control the specified service

func (*Instance) Env

func (c *Instance) Env() []string

Env provides the combined environment variables for this service command

func (*Instance) Getenv

func (c *Instance) Getenv(key string) string

Getenv returns the environment variable value for the provided key, if present. Env overrides are consulted first, followed by service env settings, then the os Env.

func (*Instance) StartAsync

func (c *Instance) StartAsync(cfg services.OperationConfig, task tracker.Task) error

StartAsync starts the service in the background Will block until the service is known to have started successfully. If the service fails to launch, an error will be returned.

func (*Instance) StopSync

func (c *Instance) StopSync(cfg services.OperationConfig, overrides services.ContextOverride, task tracker.Task) error

StopSync stops this service in a synchronous manner

type State

type State string
const (
	StateStarting State = "STARTING"
	StateRunning  State = "RUNNING"
	StateStopped  State = "STOPPED"
	StateDied     State = "DIED"
	StateUnknown  State = "UNKNOWN"
)

type Status

type Status struct {
	State       State                   `json:"status"`
	Ports       []string                `json:"ports"` // Ports opened by this instance
	StdoutLines int                     `json:"stdoutLines"`
	StderrLines int                     `json:"stderrLines"`
	StartTime   time.Time               `json:"startTime"`
	MemoryInfo  *process.MemoryInfoStat `json:"memoryInfo,omitempty"`
}

Jump to

Keyboard shortcuts

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