instance

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 25 Imported by: 0

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 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,
	processes Processes,
	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 Processes added in v1.8.12

type Processes interface {
	// PidExists returns true iff the process with the provided PID exists.
	PidExists(pid int) (bool, error)

	// PidCommandMatches returns true iff the process with the provided PID exists,
	// and its command contains the provided string.
	PidCommandMatches(pid int, value string) (bool, error)

	// SendSignal issues the specified signal to the process running with the provided PID.
	// If the PID does not exist, no error will be returned.
	SendSignal(pid int, signal syscall.Signal) error

	// KillGroup sends a kill signal to the group containing the provided PID.
	// If sudo is true, the group will be killed with superuser priviledges,
	// it will be assumed that these priviledges have been given to this process on launch.
	KillGroup(pid int, sudo bool) error
}

Processes provides functions for working with processes

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"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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