Documentation ¶
Overview ¶
Package svc abstracts starting and stopping processes locally so they can be integrated into Mage targets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrNotReady ¶
type ErrNotReady struct{}
ErrNotReady indicates that the service is not (yet) ready. This is returned by functions used by Check to test if the service is fully ready.
func (ErrNotReady) Error ¶
func (ErrNotReady) Error() string
type Interface ¶
type Interface interface { // Start returns a Mage target that will start the service if it is not already // running and wait until it is ready based on the configured checks. Start() mg.Fn // Stop returns a Mage target that will stop the service if it is already running // and clean up its pidfile. Stop() mg.Fn // Status returns the status of the service. Status(context.Context) *Status }
Interface describes the interface provided by a configured service.
type Option ¶
type Option func(*config)
An Option improves the configuration.
func Check ¶
Check specifies functions that confirms the service is actually started and ready. The check should return ErrNotReady if the service is not yet ready.
func Dir ¶
Dir specifies the starting directory for the service. If the directory does not exist, it will be created.
func HTTPCheck ¶
HTTPCheck specifies that getting a HTTP URL that should return a given status as a check for service readiness.
type Status ¶
type Status struct { // Name is the configured name of the service. Name string `json:"name"` // PID is nonzero if the PID file could be read. If this is zero, then all the // other fields will also be zero. PID int `json:"pid,omitempty"` // Started is the time the PID file was written. Started time.Time `json:"started,omitempty"` // Running is true if the PID matches a running process and the PID file was // modified after the last time the system started. Running bool `json:"running,omitempty"` // Ready is true if the service passed all of its checks. Ready bool `json:"ready,omitempty"` }
Status explains the status of a service, as understood by this package.