Documentation ¶
Overview ¶
Package service provides the Service interface for managing the life-cycle of a single binary.
Index ¶
- type Base
- type Cmd
- func (c *Cmd) Healthy(ctx context.Context) error
- func (c *Cmd) Kill()
- func (c *Cmd) Monitor()
- func (c *Cmd) Start(ctx context.Context) error
- func (c *Cmd) StdinPipe() (io.WriteCloser, error)
- func (c *Cmd) Stop(ctx context.Context) error
- func (c *Cmd) StopMonitoring()
- func (c *Cmd) Wait(ctx context.Context) error
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { diagnostics.Diagnostics // contains filtered or unexported fields }
Base is a base struct for defining a service.
func NewBase ¶
func NewBase(name string, d diagnostics.Diagnostics) *Base
NewBase creates a new Base service with the given component name.
func (*Base) Healthy ¶
Healthy returns nil if this service has been started and has not been stopped.
type Cmd ¶
type Cmd struct { *Base // contains filtered or unexported fields }
Cmd is a service that starts an external executable.
func NewCmd ¶
func NewCmd(name string, d diagnostics.Diagnostics, exe string, xvfb bool, env map[string]string, args ...string) (*Cmd, error)
NewCmd creates a new service for starting an external server on the host machine.
func (*Cmd) Healthy ¶
Healthy returns nil if c has been started and the process it started is still running.
func (*Cmd) Monitor ¶
func (c *Cmd) Monitor()
Monitor waits for cmd to exit, and when it does, logs an infrastructure failure if it exited abnormally.
func (*Cmd) Start ¶
Start starts the executable, waits for it to become healhy, and monitors it to ensure that it stays healthy.
func (*Cmd) StdinPipe ¶
func (c *Cmd) StdinPipe() (io.WriteCloser, error)
StdinPipe returns a pipe that will be connected to the command's standard input when the command starts.
func (*Cmd) StopMonitoring ¶
func (c *Cmd) StopMonitoring()
StopMonitoring turns off reporting of infrastructure failures should this process exit.
type Server ¶
type Server struct { *Cmd // contains filtered or unexported fields }
Server is a service that starts an external server.
func NewServer ¶
func NewServer(name string, d diagnostics.Diagnostics, exe, healthPattern string, xvfb bool, timeout time.Duration, env map[string]string, args ...string) (*Server, error)
NewServer creates a new service for starting an external server on the host machine. Args should contain {port}, which will be replaced with the selected port number.