Help us shape the future of Go! Take the 2026 Go Developer Survey

shim

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubCommand is the first argument to the clone of the nomad agent process
	// for invoking the exec2 driver sandbox shim.
	SubCommand = "exec2-shim"

	// ExitWrongArgs indicates the shim has terminated early due to recieving
	// the wrong expected arguments. We use a special return code here since logs
	// will not have been configured yet.
	ExitWrongArgs = 40

	// ExitBadLogging indicates the shim has terminated early due to being unable
	// to open stdout or stderr output files (fifos).
	ExitBadLogging = 41
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment struct {
	User         string            // user the command will run as (may be empty / synthetic)
	OutPipe      string            // io pipe path for stdout
	ErrPipe      string            // io pipe path for stderr
	Env          map[string]string // environment variables
	TaskDir      string            // task directory
	Cgroup       string            // task cgroup path
	Net          string            // allocation network namespace path
	Memory       uint64            // memory in megabytes
	MemoryMax    uint64            // memory_max in megabytes
	CPUBandwidth uint64            // cpu / cores bandwidth
	OOMScoreAdj  int               // oom_score_adj for the task
}

Environment represents runtime configuration.

type ExecTwo

type ExecTwo interface {
	// Start the Task process.
	Start(context.Context) error

	// PID returns the process ID associated with exec.
	//
	// Must only be called after Start.
	PID() int

	// Wait on the process (until exit).
	//
	// Must only be called after Start.
	WaitCh() process.WaitCh

	// Stats returns current resource utilization.
	//
	// Must only be called after Start.
	Stats() *resources.Utilization

	// Signal [kill()] the process.
	//
	// Must be called after Start.
	Signal(string) error

	// Stop the process.
	//
	// Must be called after Start.
	Stop(string, time.Duration) error
}

func New

func New(env *Environment, opts *Options) ExecTwo

New an ExecTwo, an instantiation of the exec2 driver.

func Recover

func Recover(pid int, env *Environment) ExecTwo

Recover an ExecTwo, an already running instance of the execc2 driver.

type Options

type Options struct {
	Command        string
	Arguments      []string
	UnveilPaths    []string
	UnveilDefaults bool
	OOMScoreAdj    int
}

Options represent Task configuration options.

Jump to

Keyboard shortcuts

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