executor

package
v0.0.0-...-f6ab670 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Overview

Package executor contains general purpose command executing objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IExecutor

type IExecutor interface {
	Start(*model.WorkerConfig) (*model.Process, error)
	Processes() ([]OsProcess, error)
	IsPidRunning(pid int) (bool, error)
	Kill(pid int) error
}

IExecutor is the interface type for ProcessExecutor.

func NewProcessExecutor

func NewProcessExecutor(log log.T) IExecutor

NewProcessExecutor returns process executor

type OsProcess

type OsProcess struct {
	Pid        int
	PPid       int
	Executable string
	State      string
}

OsProcess represent the process information for the worker, such as pid and binary name

type ProcessExecutor

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

ProcessExecutor is specially added for testing purposes

func (*ProcessExecutor) IsPidRunning

func (exc *ProcessExecutor) IsPidRunning(pid int) (bool, error)

IsPidRunning returns true if process with pid is running

func (*ProcessExecutor) Kill

func (exc *ProcessExecutor) Kill(pid int) error

func (*ProcessExecutor) Processes

func (exc *ProcessExecutor) Processes() ([]OsProcess, error)

Processes returns running processes on the instance

func (*ProcessExecutor) Start

func (exc *ProcessExecutor) Start(workerConfig *model.WorkerConfig) (*model.Process, error)

Start starts a list of shell commands in the given working directory. Returns process started, an exit code (0 if successfully launch, 1 if error launching process), and a set of errors. The errors need not be fatal - the output streams may still have data even though some errors are reported. For example, if the command got killed while executing, the streams will have whatever data was printed up to the kill point, and the errors will indicate that the process got terminated.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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