Documentation ¶
Index ¶
- Variables
- type Manager
- func (pm *Manager) Add(description string, cancel context.CancelFunc) int64
- func (pm *Manager) Cancel(pid int64)
- func (pm *Manager) Exec(desc, cmdName string, args ...string) (string, string, error)
- func (pm *Manager) ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (string, string, error)
- func (pm *Manager) ExecDirEnv(timeout time.Duration, dir, desc string, env []string, cmdName string, ...) (string, string, error)
- func (pm *Manager) ExecDirEnvStdIn(timeout time.Duration, dir, desc string, env []string, stdIn io.Reader, ...) (string, string, error)
- func (pm *Manager) ExecTimeout(timeout time.Duration, desc, cmdName string, args ...string) (string, string, error)
- func (pm *Manager) Processes() []*Process
- func (pm *Manager) Remove(pid int64)
- type Process
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExecTimeout represent a timeout error ErrExecTimeout = errors.New("Process execution timeout") // DefaultContext is the default context to run processing commands in DefaultContext = context.Background() )
Functions ¶
This section is empty.
Types ¶
type Manager ¶ added in v1.1.0
type Manager struct {
// contains filtered or unexported fields
}
Manager knows about all processes and counts PIDs.
func GetManager ¶ added in v1.1.0
func GetManager() *Manager
GetManager returns a Manager and initializes one as singleton if there's none yet
func (*Manager) Add ¶ added in v1.1.0
func (pm *Manager) Add(description string, cancel context.CancelFunc) int64
Add a process to the ProcessManager and returns its PID.
func (*Manager) ExecDir ¶ added in v1.1.0
func (pm *Manager) ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (string, string, error)
ExecDir a command and use the default timeout.
func (*Manager) ExecDirEnv ¶ added in v1.1.0
func (pm *Manager) ExecDirEnv(timeout time.Duration, dir, desc string, env []string, cmdName string, args ...string) (string, string, error)
ExecDirEnv runs a command in given path and environment variables, and waits for its completion up to the given timeout (or DefaultTimeout if -1 is given). Returns its complete stdout and stderr outputs and an error, if any (including timeout)
func (*Manager) ExecDirEnvStdIn ¶ added in v1.9.5
func (pm *Manager) ExecDirEnvStdIn(timeout time.Duration, dir, desc string, env []string, stdIn io.Reader, cmdName string, args ...string) (string, string, error)
ExecDirEnvStdIn runs a command in given path and environment variables with provided stdIN, and waits for its completion up to the given timeout (or DefaultTimeout if -1 is given). Returns its complete stdout and stderr outputs and an error, if any (including timeout)
func (*Manager) ExecTimeout ¶ added in v1.1.0
func (pm *Manager) ExecTimeout(timeout time.Duration, desc, cmdName string, args ...string) (string, string, error)
ExecTimeout a command and use a specific timeout duration.