process

package
v1.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package process provides process execution implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDockerAvailable

func IsDockerAvailable(ctx context.Context) bool

IsDockerAvailable checks if Docker is available and running.

func ReadPIDFile

func ReadPIDFile(path string) (int, error)

ReadPIDFile reads a PID from a file.

Types

type ContainerError

type ContainerError struct {
	ContainerID string
	Operation   string
	Message     string
}

ContainerError is returned when Docker container operations fail.

func (*ContainerError) Error

func (e *ContainerError) Error() string

type DockerExecutorImpl

type DockerExecutorImpl struct {
	*LocalExecutor // Embed for local process fallback
}

DockerExecutorImpl implements DockerExecutor for Docker container execution.

func NewDockerExecutor

func NewDockerExecutor() *DockerExecutorImpl

NewDockerExecutor creates a new DockerExecutorImpl.

func (*DockerExecutorImpl) ContainerLogs

func (e *DockerExecutorImpl) ContainerLogs(ctx context.Context, containerID string, lines int) ([]string, error)

ContainerLogs retrieves container logs.

func (*DockerExecutorImpl) ExecInContainer

func (e *DockerExecutorImpl) ExecInContainer(ctx context.Context, containerID string, command []string) ([]byte, error)

ExecInContainer executes a command inside a running container.

func (*DockerExecutorImpl) FindContainerByName

func (e *DockerExecutorImpl) FindContainerByName(ctx context.Context, name string) (ports.DockerHandle, error)

FindContainerByName finds a container by name and returns a handle.

func (*DockerExecutorImpl) ImageExists

func (e *DockerExecutorImpl) ImageExists(ctx context.Context, image string) bool

ImageExists checks if a Docker image exists locally.

func (*DockerExecutorImpl) IsRunning

func (e *DockerExecutorImpl) IsRunning(handle ports.ProcessHandle) bool

IsRunning checks if a process is running.

func (*DockerExecutorImpl) Kill

func (e *DockerExecutorImpl) Kill(handle ports.ProcessHandle) error

Kill forcefully terminates a process.

func (*DockerExecutorImpl) Logs

func (e *DockerExecutorImpl) Logs(handle ports.ProcessHandle, lines int) ([]string, error)

Logs retrieves logs from a process.

func (*DockerExecutorImpl) PullImage

func (e *DockerExecutorImpl) PullImage(ctx context.Context, image string) error

PullImage pulls a Docker image.

func (*DockerExecutorImpl) RemoveContainer

func (e *DockerExecutorImpl) RemoveContainer(ctx context.Context, containerID string, force bool) error

RemoveContainer removes a Docker container.

func (*DockerExecutorImpl) RunContainer

RunContainer starts a Docker container.

func (*DockerExecutorImpl) Start

Start launches a process (delegates to local executor for non-Docker commands).

func (*DockerExecutorImpl) Stop

func (e *DockerExecutorImpl) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error

Stop gracefully stops a process.

func (*DockerExecutorImpl) StopContainer

func (e *DockerExecutorImpl) StopContainer(ctx context.Context, containerID string, timeout time.Duration) error

StopContainer stops a Docker container.

type ExecutionError

type ExecutionError struct {
	Operation string
	Message   string
}

ExecutionError is returned when process execution fails.

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

type ImageError

type ImageError struct {
	Image   string
	Message string
}

ImageError is returned when Docker image operations fail.

func (*ImageError) Error

func (e *ImageError) Error() string

type LocalExecutor

type LocalExecutor struct{}

LocalExecutor implements ProcessExecutor for local process execution.

func NewLocalExecutor

func NewLocalExecutor() *LocalExecutor

NewLocalExecutor creates a new LocalExecutor.

func (*LocalExecutor) FindProcessByPID

func (e *LocalExecutor) FindProcessByPID(pid int, logPath string) (ports.ProcessHandle, error)

FindProcessByPID finds a process by PID and returns a handle. Note: The returned handle has done=nil because there's no monitoring goroutine for externally-discovered processes. Stop() will fall back to polling-based termination detection when done is nil, and Wait() will return immediately.

func (*LocalExecutor) IsRunning

func (e *LocalExecutor) IsRunning(handle ports.ProcessHandle) bool

IsRunning checks if a process is running.

func (*LocalExecutor) Kill

func (e *LocalExecutor) Kill(handle ports.ProcessHandle) error

Kill forcefully terminates a process.

func (*LocalExecutor) Logs

func (e *LocalExecutor) Logs(handle ports.ProcessHandle, lines int) ([]string, error)

Logs retrieves the last N lines from the process log.

func (*LocalExecutor) Start

Start launches a new process.

func (*LocalExecutor) Stop

func (e *LocalExecutor) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error

Stop gracefully stops a process with timeout.

type NotRunningError

type NotRunningError struct {
	PID int
}

NotRunningError is returned when a process is not running.

func (*NotRunningError) Error

func (e *NotRunningError) Error() string

Jump to

Keyboard shortcuts

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