Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPathNotSet indicates a Cmd object which doesn't have a path value ErrPathNotSet = fmt.Errorf("cmd: no path specified") // ErrArgsRequiresPathAsFirstArg indicates a Cmd object which doesn't have // args[0] == path ErrArgsRequiresPathAsFirstArg = fmt.Errorf("cmd: args[0] un-equal to path") )
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
Cmd represents an executable command NB(prateek): golang's os/exec package makes an implicit requirement that Args[0] to be set to Path, iff Args is set at all. This package follows the convention but makes that requirement explicit. ProcessMonitor reports error when being constructed.
type EnvMap ¶
EnvMap is a map of Key-Value pairs representing the environment variables. NB(prateek): these are a set of 'delta' vars, i.e. they are appended to the vars already present in `os.Environ()`.
type ProcessListener ¶
type ProcessListener interface { // OnComplete is executed in the event of process termination without error OnComplete() // OnError is executed in the event of process termination with error OnError(error) }
ProcessListener permits users of the API to be notified of process termination
func NewProcessListener ¶
func NewProcessListener( completeFn func(), errFn func(error), ) ProcessListener
NewProcessListener returns a new ProcessListener
type ProcessMonitor ¶
type ProcessMonitor interface { // Start starts the provided process Start() error // Stop stops any running process // NB(prateek): the golang runtime reports error inconsistently upon calling // `process.Kill()`. Consequently, it is not guaranteed which notification method // of the ProcessListener (OnComplete/OnError) is invoked upon process termination. // Refer https://github.com/golang/go/blob/master/src/os/exec_plan9.go#L51-L63 Stop() error // Running returns a flag indicating if the process is running Running() bool // Err returns any error encountered Err() error // Close releases any held resources Close() error // StdoutPath returns the path to the process stdout file StdoutPath() string // StderrPath returns the path to the process stderr file StderrPath() string }
ProcessMonitor provides necessary controls to supervise a process
func NewProcessMonitor ¶
func NewProcessMonitor(cmd Cmd, pl ProcessListener) (ProcessMonitor, error)
NewProcessMonitor creates a new ProcessMonitor