process

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecTimeout represent a timeout error
	ErrExecTimeout = errors.New("Process execution timeout")
)

Functions

This section is empty.

Types

type Manager added in v1.1.0

type Manager struct {
	Processes map[int64]*Process
	// 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, cmd *exec.Cmd) int64

Add a process to the ProcessManager and returns its PID.

func (*Manager) Exec added in v1.1.0

func (pm *Manager) Exec(desc, cmdName string, args ...string) (string, string, error)

Exec a command and use the default timeout.

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) 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.

func (*Manager) Kill added in v1.1.0

func (pm *Manager) Kill(pid int64) error

Kill and remove a process from list.

func (*Manager) Remove added in v1.1.0

func (pm *Manager) Remove(pid int64)

Remove a process from the ProcessManager.

type Process

type Process struct {
	PID         int64 // Process ID, not system one.
	Description string
	Start       time.Time
	Cmd         *exec.Cmd
}

Process represents a working process inherit from Gogs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL