Documentation ¶
Overview ¶
Package services provides mechanisms to start multiple services in the background
Index ¶
Constants ¶
View Source
const (
DefaultPollInterval = 100 * time.Millisecond
)
View Source
const DefaultServiceTimeout = 5 * time.Second
Variables ¶
View Source
var ( ServiceTimeoutError = errors.New("timed out waiting for service to be ready") SupervisorTimeoutError = errors.New("timed out waiting for services to stop") )
Functions ¶
This section is empty.
Types ¶
type CommandService ¶ added in v1.3.0
type CommandService struct { // Name that identifies the service. Name string // Port used to verify if the service is ready. HealthcheckPort int // Path to the service binary. Path string // Args to the service binary. Args []string // Environment variables. Env []string // Working Directory WorkDir string }
CommandService encapsulates the execution of an executable via exec.Command. It assumes the executable accepts TCP connections at HealthcheckPort, which it uses to determine if it is ready or not.
func (CommandService) Start ¶ added in v1.3.0
func (s CommandService) Start(ctx context.Context, ready chan<- struct{}) error
func (CommandService) String ¶ added in v1.3.0
func (s CommandService) String() string
type HttpService ¶ added in v1.3.0
func (HttpService) Start ¶ added in v1.3.0
func (s HttpService) Start(ctx context.Context, ready chan<- struct{}) error
func (HttpService) String ¶ added in v1.3.0
func (s HttpService) String() string
type ServerManager ¶ added in v1.3.0
type ServerManager struct { // Name that identifies the service. Name string // Port used to verify if the service is ready. HealthcheckPort int // Path to the service binary. Path string // Args to the service binary. Args []string // Environment variables. Env []string // Bypass the log and write directly to stdout/stderr. BypassLog bool // Working Directory WorkDir string }
ServerManager is a variation of CommandService used to manually stop the orphaned cartesi-machines left after server-manager exits. For more information, check https://github.com/cartesi/server-manager/issues/18
func (ServerManager) Start ¶ added in v1.3.0
func (s ServerManager) Start(ctx context.Context, ready chan<- struct{}) error
func (ServerManager) String ¶ added in v1.3.0
func (s ServerManager) String() string
type SupervisorService ¶ added in v1.3.0
type SupervisorService struct { // Name of the service Name string // Services to be managed Services []Service // The amount of time to wait for a service to be ready. // Default is 5 seconds ReadyTimeout time.Duration // The amount of time to wait for a service to exit after // its context is canceled. Default is 5 seconds StopTimeout time.Duration }
SupervisorService is a simple implementation of a supervisor. It runs its services until the first returns a non-nil error.
func (SupervisorService) Start ¶ added in v1.3.0
func (s SupervisorService) Start(ctx context.Context, ready chan<- struct{}) error
func (SupervisorService) String ¶ added in v1.3.0
func (s SupervisorService) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
This file creates a dummy webserver with the sole pupose of being used as a binary to test the services.Service struct
|
This file creates a dummy webserver with the sole pupose of being used as a binary to test the services.Service struct |
Click to show internal directories.
Click to hide internal directories.