service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Overview

Package service provides the Service interface for managing the life-cycle of a single binary.

Index

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

func (b *Base) Healthy(context.Context) error

Healthy returns nil if this service has been started and has not been stopped.

func (*Base) Name

func (b *Base) Name() string

Name returns the component name used in error messages.

func (*Base) Start

func (b *Base) Start(context.Context) error

Start makes this service as started, failing if it has already been started.

func (*Base) Stop

func (b *Base) Stop(context.Context) error

Stop makes this service as stopped, failing if it hasn't been started or has already 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

func (c *Cmd) Healthy(ctx context.Context) error

Healthy returns nil if c has been started and the process it started is still running.

func (*Cmd) Kill

func (c *Cmd) Kill()

Kill kills the process.

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

func (c *Cmd) Start(ctx context.Context) error

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

func (c *Cmd) Stop(ctx context.Context) error

Stop stops the executable.

func (*Cmd) StopMonitoring

func (c *Cmd) StopMonitoring()

StopMonitoring turns off reporting of infrastructure failures should this process exit.

func (*Cmd) Wait

func (c *Cmd) Wait(ctx context.Context) error

Wait waits for the command to exit or ctx to be done. If ctx is done before the command exits, then an error is returned.

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.

func (*Server) Address

func (s *Server) Address() string

Address returns the address of the server (localhost:%port%).

func (*Server) Healthy

func (s *Server) Healthy(ctx context.Context) error

Healthy returns nil if the server responds OK to requests to health page.

func (*Server) Port

func (s *Server) Port() string

Port returns the port this server is running on as a string.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the server, waits for it to become healhy, and monitors it to ensure that it stays healthy.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops the server.

Directories

Path Synopsis
Package wsl provides a Service for launching WebDriver Server Light (WSL).
Package wsl provides a Service for launching WebDriver Server Light (WSL).

Jump to

Keyboard shortcuts

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