Documentation ¶
Overview ¶
Package runner run a restart a program on signals
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRunning is the return error in the Start method ErrRunning = errors.New("Program is already running") // ErrCantKill is returned by Restart and Stop in case the process can't be killed ErrCantKill = errors.New("Process is still alive after sending the kill signal") // ErrNotRunning is retuned by the Stop and Signal command when the program is not running ErrNotRunning = errors.New("Process is not running") // ErrRunnerClosed is returned by any method when the runner is closed ErrRunnerClosed = errors.New("Runner is closed") )
var DefaultRunnerOptions = &Options{ KillWaitPeriod: time.Second, ReadyString: []string{"Listening", "Started", "Ready"}, }
DefaultRunnerOptions are used when no RunnerOptions are passed
Functions ¶
This section is empty.
Types ¶
type EventReady ¶
type EventReady struct {
Data string // Data contains the block that triggered the EventReady
}
EventReady is fired whenever the command outputs the string Listening
type EventRestart ¶
type EventRestart struct { // Err display any error that happen during stop // If Err is nil you can expect an EventStarted event Err error }
EventRestart is fired whenever Restart is called
type EventSignal ¶
type EventSignal struct { // Err display any error that happen during stop Err error }
EventSignal is fired whenever
type EventStart ¶
type EventStart struct { // Err display any error that happen during start // If Err is nil you can expect an EventStarted event Err error }
EventStart is fired whenever Start is called
type EventStarted ¶ added in v0.0.4
type EventStarted struct {
Command string
}
EventStarted is fired whenever the subprocess is started
type EventStop ¶
type EventStop struct { // Err display any error that happen during stop Err error }
EventStop is fired whenever Stop is called
type EventStopped ¶
type EventStopped struct { Output []string // Holds the command output up to MaxOutputSize ExitCode int // ExitCode holds the exit code RunTime time.Duration }
EventStopped is fired whenever the process exits
type Options ¶
type Options struct { KillWaitPeriod time.Duration // Time wait for a proces to die before callking kill ReadyString []string // ReadyString is the string that Runner looks for in the command output to send EventReady }
Options holds the runner options
type Runner ¶
type Runner struct { Events <-chan (interface{}) // Events will be fired here. The channel is not expected to be closed. // contains filtered or unexported fields }
Runner is an command runner that produces events on start/stop and restart
func New ¶
New creates a new runner for the given command if options is nil, New will use DefaultRunnerOptions
func (*Runner) Close ¶
Close stop all the internal goroutines After Close is called the runner can't be used anymore
func (*Runner) Restart ¶
Restart restart the process by calling Stop and then Restart. If the process is not runing it will be the same as calling Start
func (*Runner) Signal ¶
Signal sends a signal to the process. If the process is not running it returns ErrNotRunning