process

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateStarting = State(types.ProcessStateStarting)
	StateRunning  = State(types.ProcessStateRunning)
	StateStopping = State(types.ProcessStateStopping)
	StateStopped  = State(types.ProcessStateStopped)
	StateError    = State(types.ProcessStateError)
)

Variables

This section is empty.

Functions

func ParsePortRange

func ParsePortRange(portRange string) (int32, int32, error)

Types

type BinaryCommand

type BinaryCommand struct {
	*sync.RWMutex
	*exec.Cmd
}

func NewBinaryCommand

func NewBinaryCommand(binary string, arg ...string) (*BinaryCommand, error)

func (*BinaryCommand) Kill

func (bc *BinaryCommand) Kill()

func (*BinaryCommand) SetOutput

func (bc *BinaryCommand) SetOutput(writer io.Writer)

func (*BinaryCommand) Started

func (bc *BinaryCommand) Started() bool

func (*BinaryCommand) Stop

func (bc *BinaryCommand) Stop()

func (*BinaryCommand) StopWithSignal

func (bc *BinaryCommand) StopWithSignal(signal syscall.Signal)

type BinaryExecutor

type BinaryExecutor struct{}

func (*BinaryExecutor) NewCommand

func (be *BinaryExecutor) NewCommand(name string, arg ...string) (Command, error)

type Command

type Command interface {
	Run() error
	SetOutput(io.Writer)
	Started() bool
	Stop()
	StopWithSignal(signal syscall.Signal)
	Kill()
}

type Executor

type Executor interface {
	NewCommand(name string, arg ...string) (Command, error)
}

type GRPCHealthChecker

type GRPCHealthChecker struct{}

func (*GRPCHealthChecker) IsRunning

func (c *GRPCHealthChecker) IsRunning(address string) bool

func (*GRPCHealthChecker) WaitForRunning

func (c *GRPCHealthChecker) WaitForRunning(address, name string, stopCh chan struct{}) bool

type HealthChecker

type HealthChecker interface {
	IsRunning(address string) bool
	WaitForRunning(address, name string, stopCh chan struct{}) bool
}

type Manager

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

func NewManager

func NewManager(portRange string, logsDir string, shutdownCh chan error) (*Manager, error)

func (*Manager) ProcessCreate

func (pm *Manager) ProcessCreate(ctx context.Context, req *rpc.ProcessCreateRequest) (ret *rpc.ProcessResponse, err error)

ProcessCreate will create a process according to the request. If the specified process name exists already, the creation will fail.

func (*Manager) ProcessDelete

func (pm *Manager) ProcessDelete(ctx context.Context, req *rpc.ProcessDeleteRequest) (ret *rpc.ProcessResponse, err error)

ProcessDelete will delete the process named by the request. If the process doesn't exist, the deletion will return with ErrorNotFound

func (*Manager) ProcessGet

func (pm *Manager) ProcessGet(ctx context.Context, req *rpc.ProcessGetRequest) (*rpc.ProcessResponse, error)

ProcessGet will get a process named by the request. If the process doesn't exist, the call will return with ErrorNotFound

func (*Manager) ProcessList

func (pm *Manager) ProcessList(ctx context.Context, req *rpc.ProcessListRequest) (*rpc.ProcessListResponse, error)

func (*Manager) ProcessLog

func (*Manager) ProcessReplace

func (pm *Manager) ProcessReplace(ctx context.Context, req *rpc.ProcessReplaceRequest) (ret *rpc.ProcessResponse, err error)

ProcessReplace will replace a process with the new process according to the request. If the specified process name doesn't exist already, the replace will fail.

func (*Manager) ProcessWatch

func (pm *Manager) ProcessWatch(req *empty.Empty, srv rpc.ProcessManagerService_ProcessWatchServer) (err error)

func (*Manager) Shutdown

func (pm *Manager) Shutdown()

func (*Manager) Subscribe

func (pm *Manager) Subscribe() (<-chan interface{}, error)

func (*Manager) VersionGet

func (pm *Manager) VersionGet(ctx context.Context, empty *empty.Empty) (*rpc.VersionResponse, error)

type MockCommand

type MockCommand struct {
	*sync.RWMutex

	Binary string
	Args   []string
	// contains filtered or unexported fields
}

func NewMockCommand

func NewMockCommand(name string, arg ...string) *MockCommand

func (*MockCommand) Kill

func (mc *MockCommand) Kill()

func (*MockCommand) Run

func (mc *MockCommand) Run() error

func (*MockCommand) SetOutput

func (mc *MockCommand) SetOutput(writer io.Writer)

func (*MockCommand) Started

func (mc *MockCommand) Started() bool

func (*MockCommand) Stop

func (mc *MockCommand) Stop()

func (*MockCommand) StopWithSignal

func (mc *MockCommand) StopWithSignal(signal syscall.Signal)

type MockExecutor

type MockExecutor struct {
	CreationHook func(cmd *MockCommand) (*MockCommand, error)
}

func (*MockExecutor) NewCommand

func (me *MockExecutor) NewCommand(name string, arg ...string) (Command, error)

type MockHealthChecker

type MockHealthChecker struct{}

func (*MockHealthChecker) IsRunning

func (c *MockHealthChecker) IsRunning(address string) bool

func (*MockHealthChecker) WaitForRunning

func (c *MockHealthChecker) WaitForRunning(address, name string, stopCh chan struct{}) bool

type Process

type Process struct {
	Name      string
	Binary    string
	Args      []string
	PortCount int32
	PortArgs  []string

	UUID      string
	State     State
	ErrorMsg  string
	PortStart int32
	PortEnd   int32

	UpdateCh chan *Process
	// contains filtered or unexported fields
}

func (*Process) IsStopped

func (p *Process) IsStopped() bool

func (*Process) RPCResponse

func (p *Process) RPCResponse() *rpc.ProcessResponse

func (*Process) Start

func (p *Process) Start() error

func (*Process) Stop

func (p *Process) Stop()

func (*Process) StopWithSignal

func (p *Process) StopWithSignal(signal syscall.Signal)

type State

type State string

Jump to

Keyboard shortcuts

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