Documentation
¶
Index ¶
- type OutputWriter
- type Process
- func (r *Process) Env(vars map[string]string) contractsprocess.Process
- func (r *Process) Input(in io.Reader) contractsprocess.Process
- func (r *Process) OnOutput(handler contractsprocess.OnOutputFunc) contractsprocess.Process
- func (r *Process) Path(path string) contractsprocess.Process
- func (r *Process) Quietly() contractsprocess.Process
- func (r *Process) Run(name string, args ...string) (contractsprocess.Result, error)
- func (r *Process) Start(name string, args ...string) (contractsprocess.Running, error)
- func (r *Process) TTY() contractsprocess.Process
- func (r *Process) Timeout(timeout time.Duration) contractsprocess.Process
- func (r *Process) WithContext(ctx context.Context) contractsprocess.Process
- type Result
- func (r *Result) Command() string
- func (r *Result) ErrorOutput() string
- func (r *Result) ExitCode() int
- func (r *Result) Failed() bool
- func (r *Result) Output() string
- func (r *Result) SeeInErrorOutput(needle string) bool
- func (r *Result) SeeInOutput(needle string) bool
- func (r *Result) Successful() bool
- type Running
- func (r *Running) Command() string
- func (r *Running) ErrorOutput() string
- func (r *Running) Kill() error
- func (r *Running) LatestErrorOutput() string
- func (r *Running) LatestOutput() string
- func (r *Running) Output() string
- func (r *Running) PID() int
- func (r *Running) Running() bool
- func (r *Running) Signal(sig os.Signal) error
- func (r *Running) Stop(timeout time.Duration, sig ...os.Signal) error
- func (r *Running) Wait() contractsprocess.Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
func NewOutputWriter ¶
func NewOutputWriter(typ contractsprocess.OutputType, handler contractsprocess.OnOutputFunc) *OutputWriter
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
func (*Process) OnOutput ¶
func (r *Process) OnOutput(handler contractsprocess.OnOutputFunc) contractsprocess.Process
func (*Process) Quietly ¶
func (r *Process) Quietly() contractsprocess.Process
func (*Process) TTY ¶
func (r *Process) TTY() contractsprocess.Process
func (*Process) WithContext ¶
func (r *Process) WithContext(ctx context.Context) contractsprocess.Process
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) ErrorOutput ¶
func (*Result) SeeInErrorOutput ¶
func (*Result) SeeInOutput ¶
func (*Result) Successful ¶
type Running ¶
type Running struct {
// contains filtered or unexported fields
}
func (*Running) ErrorOutput ¶
func (*Running) LatestErrorOutput ¶
func (*Running) LatestOutput ¶
func (*Running) Running ¶
Running actively queries the OS to see if the process still exists.
NOTE: This method returns `true` for a "zombie" process (one that has terminated but has not been reaped by a call to `Wait()`). Due to this, a monitoring loop requires a concurrent call to `result.Wait()` to ensure termination.
Correct Usage Example:
done := make(chan struct{})
result, _ := process.New().Start("sleep", "2")
go func() {
defer close(done)
// This loop will continue as long as the process is running OR a zombie.
for result.Running() {
fmt.Println("Process is still running...")
time.Sleep(500 * time.Millisecond)
}
}()
// This call is mandatory. It blocks, reaps the zombie, and allows the goroutine to exit.
result.Wait()
<-done // Wait for monitoring goroutine to finish.
func (*Running) Stop ¶
Stop gracefully stops the process by sending SIGTERM and waiting for a timeout.
func (*Running) Wait ¶
func (r *Running) Wait() contractsprocess.Result
Click to show internal directories.
Click to hide internal directories.