gitea: code.gitea.io/gitea/modules/process Index | Files

package process

import "code.gitea.io/gitea/modules/process"

Index

Package Files

manager.go

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

type Error Uses

type Error struct {
    PID         int64
    Description string
    Err         error
    CtxErr      error
    Stdout      string
    Stderr      string
}

Error is a wrapped error describing the error results of Process Execution

func (*Error) Error Uses

func (err *Error) Error() string

func (*Error) Unwrap Uses

func (err *Error) Unwrap() error

Unwrap implements the unwrappable implicit interface for go1.13 Unwrap()

type Manager Uses

type Manager struct {
    // contains filtered or unexported fields
}

Manager knows about all processes and counts PIDs.

func GetManager Uses

func GetManager() *Manager

GetManager returns a Manager and initializes one as singleton if there's none yet

func (*Manager) Add Uses

func (pm *Manager) Add(description string, cancel context.CancelFunc) int64

Add a process to the ProcessManager and returns its PID.

func (*Manager) Cancel Uses

func (pm *Manager) Cancel(pid int64)

Cancel a process in the ProcessManager.

func (*Manager) Exec Uses

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

Exec a command and use the default timeout.

func (*Manager) ExecDir Uses

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 Uses

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 Uses

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 Uses

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) Processes Uses

func (pm *Manager) Processes() []*Process

Processes gets the processes in a thread safe manner

func (*Manager) Remove Uses

func (pm *Manager) Remove(pid int64)

Remove a process from the ProcessManager.

type Process Uses

type Process struct {
    PID         int64 // Process ID, not system one.
    Description string
    Start       time.Time
    Cancel      context.CancelFunc
}

Process represents a working process inheriting from Gitea.

Package process imports 9 packages (graph) and is imported by 66 packages. Updated 2020-07-25. Refresh now. Tools for package owners.