Documentation ¶
Overview ¶
Package process holds process management code for direct interaction with processes
Index ¶
- type Process
- func (p *Process) GetReturnCode() int
- func (p *Process) GetReturnStatus() string
- func (p *Process) GetStatus() string
- func (p *Process) IsRunning() bool
- func (p *Process) Kill() error
- func (p *Process) Reset() error
- func (p *Process) SendSignal(sig os.Signal) error
- func (p *Process) Start() error
- func (p *Process) Stop() error
- func (p *Process) StopOrKillTimeout(timeout time.Duration) error
- func (p *Process) UpdateCmd(command string, args []string, workingDir string, env []string, ...)
- func (p *Process) WaitForCompletion() error
- func (p *Process) Write(data []byte) (int, error)
- func (p *Process) WriteString(toWrite string) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Process ¶
type Process struct { Stderr io.Reader Stdout io.Reader Stdin io.WriteCloser StdinMutex sync.Mutex DoneChan chan bool // contains filtered or unexported fields }
Process is a representation of a command to be run and access to its stdin/out/err
func NewProcess ¶
func NewProcess(cmd string, args []string, workingDir string, logger *log.Logger, env []string, copySystemEnv bool) (*Process, error)
NewProcess returns a ready to use process object with the given options. If any errors occur during creation and setup, they are returned
func (*Process) GetReturnCode ¶
GetReturnCode returns the exit code of the process as an int. Calling this on a Process that has not been started will panic
func (*Process) GetReturnStatus ¶
GetReturnStatus returns a string containing the return status of the process, an example would be "exit code 1"
func (*Process) GetStatus ¶
GetStatus returns the current status of the process, including memory and CPU usage
func (*Process) SendSignal ¶
SendSignal sends the given signal to the underlying process
func (*Process) StopOrKillTimeout ¶
StopOrKillTimeout asks the process to stop and waits for the configured timeout, after which it kills the process
func (*Process) UpdateCmd ¶
func (p *Process) UpdateCmd(command string, args []string, workingDir string, env []string, copySystemEnv bool)
UpdateCmd sets the command and arguments to be used when creating the exec.Cmd used internally. It is safe for concurrent use. Note that this will only take effect on the next reset of the Process object
func (*Process) WaitForCompletion ¶
WaitForCompletion blocks until the Process's command has completed. If an error occurs while waiting, it is returned