supervisor

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package supervisor owns the two PID-1 responsibilities of weft-init: (1) reaping every orphaned child the kernel reparents to us, and (2) supervising the user-declared containers — start, watch, restart per policy, stop cleanly.

Splitting them matters: the reaper must run unconditionally even for processes we never started (containerd-style runtimes fork helpers we don't track), whereas the supervisor only watches the PIDs it knows about.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reaped

type Reaped struct {
	PID    int
	Status syscall.WaitStatus
	Rusage syscall.Rusage
}

Reaped is one zombie collection event.

type Reaper

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

Reaper consumes SIGCHLD and Wait4()'s every child the kernel hands us. Exits the goroutine cleanly when ctx is cancelled.

Reaped child PIDs and their status are published on the returned channel so the per-container Supervisor can correlate exits to containers it cares about. The channel is closed when the reaper exits.

func NewReaper

func NewReaper(log *slog.Logger) *Reaper

func (*Reaper) Events

func (r *Reaper) Events() <-chan Reaped

Events returns the channel of reaped children. Receivers MUST drain it ; a full buffer drops events to the log (zombies are already cleaned, only correlation is lost).

func (*Reaper) Run

func (r *Reaper) Run(ctx context.Context)

Run blocks until ctx is cancelled. It must be called exactly once. Subscribes to SIGCHLD before doing the initial drain so we don't miss any signal that arrived before we were ready.

type Supervisor

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

Supervisor drives the lifecycle of one Pod's containers via an OCI runtime. It does NOT prepare the bundles (rootfs unpacking and config.json generation live in the bundler package); it receives ready-to-run bundle directories and a runtime client.

func New

func New(log *slog.Logger, rt runtime.Runtime, reaper *Reaper, spec *pod.Spec, bundles map[string]string) *Supervisor

func (*Supervisor) Run

func (s *Supervisor) Run(ctx context.Context) error

Run starts every container and blocks until ctx is cancelled OR all non-restarting containers have exited. Returns the first fatal error encountered ; per-container failures with a restart policy are not fatal.

func (*Supervisor) Stop

func (s *Supervisor) Stop(ctx context.Context, grace time.Duration)

Stop sends SIGTERM to every still-running container, waits up to grace, then SIGKILLs survivors. Disables restart for the remainder of the supervisor's life.

Jump to

Keyboard shortcuts

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