supervisor

package
v0.9.7-dev.6 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: GPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

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

func NewBackoff

func NewBackoff(minimum, maximum time.Duration) *Backoff

func (*Backoff) Next

func (b *Backoff) Next() time.Duration

func (*Backoff) Reset

func (b *Backoff) Reset()

type Child

type Child interface {
	PID() int
	Wait() error
	Terminate() error
	Kill() error
}

type CommandStarter

type CommandStarter struct {
	// ShareProcessGroup keeps a launchd service's core in the daemon's group.
	ShareProcessGroup bool
	// CommandFactory binds installed provenance and committed config for root mode.
	// The returned release closes capabilities after Start, including failure.
	CommandFactory func(context.Context) (core.CoreCommand, func() error, error)

	BinaryPath string
	DataDir    string
	ConfigPath string
	Stdout     io.Writer
	Stderr     io.Writer
}

func (CommandStarter) Start

func (s CommandStarter) Start() (Child, error)

func (CommandStarter) StartContext added in v0.9.6

func (s CommandStarter) StartContext(ctx context.Context) (Child, error)

StartContext preserves the owner's execution capability through OS Start.

type HealthChecker

type HealthChecker func(context.Context) error

type Observation

type Observation struct {
	Status      Status
	PID         int
	Restarts    uint64
	LastError   string
	NextRetryAt time.Time
	StartedAt   time.Time
}

type Options

type Options struct {
	Starter Starter
	// BeforeStart prepares each child and returns ownership held until Start completes.
	BeforeStart        func(context.Context) (release func(), err error)
	Health             HealthChecker
	Waiter             Waiter
	Now                func() time.Time
	Observe            func(Observation)
	MinimumBackoff     time.Duration
	MaximumBackoff     time.Duration
	StableAfter        time.Duration
	GracePeriod        time.Duration
	HealthInterval     time.Duration
	StopTimeout        time.Duration
	DiagnosticReporter diagnostics.Reporter
}

type Starter

type Starter interface {
	Start() (Child, error)
}

type Status

type Status string
const (
	StatusStopped  Status = "stopped"
	StatusStarting Status = "starting"
	StatusRunning  Status = "running"
	StatusBackoff  Status = "backoff"
	StatusDegraded Status = "degraded"
)

type Supervisor

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

func New

func New(options Options) *Supervisor

func (*Supervisor) Maintain added in v0.9.3

func (s *Supervisor) Maintain(ctx context.Context, work func() error) error

Maintain runs work only while the owned child and monitor are stopped. Work must not call supervisor methods. Once accepted, cancellation does not detach work: the caller waits until commit/recovery has converged. Idle maintenance preserves the stopped state and never starts a process.

func (*Supervisor) Reinstall added in v0.9.6

func (s *Supervisor) Reinstall(ctx context.Context, work func(*UpdateSession) error) error

Reinstall admits one explicit candidate installation while ordinary starts are blocked.

func (*Supervisor) Restart

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

func (*Supervisor) Run

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

func (*Supervisor) Update added in v0.9.6

func (s *Supervisor) Update(ctx context.Context, work func(*UpdateSession) error) error

Update serializes one complete core update, including trial and recovery.

func (*Supervisor) WaitForCore added in v0.9.6

func (s *Supervisor) WaitForCore()

WaitForCore starts the event loop without trying to execute a missing binary. Runtime assembly invokes it before Run for an initial installation.

type UpdateSession added in v0.9.6

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

UpdateSession owns trial processes while ordinary restart and monitoring pause.

func (*UpdateSession) KeepStopped added in v0.9.6

func (s *UpdateSession) KeepStopped()

KeepStopped preserves a stopped or missing original core after recovery.

func (*UpdateSession) PID added in v0.9.6

func (s *UpdateSession) PID() int

PID reports the owned trial or restored process, or zero when stopped.

func (*UpdateSession) Start added in v0.9.6

func (s *UpdateSession) Start(ctx context.Context) error

Start starts one process and waits for its initial health confirmation.

func (*UpdateSession) StartedAt added in v0.9.6

func (s *UpdateSession) StartedAt() time.Time

StartedAt is the actual start of the currently owned process.

func (*UpdateSession) Stop added in v0.9.6

func (s *UpdateSession) Stop() error

Stop joins the current trial process before files may be replaced again.

func (*UpdateSession) WasRunning added in v0.9.6

func (s *UpdateSession) WasRunning() bool

WasRunning reports whether the maintenance session replaced running intent.

type Waiter

type Waiter interface {
	Wait(context.Context, time.Duration) error
}

Jump to

Keyboard shortcuts

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