supervisor

package
v0.9.3-dev.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: GPL-3.0 Imports: 10 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)

type HealthChecker

type HealthChecker func(context.Context) error

type Observation

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

type Options

type Options struct {
	Starter        Starter
	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
}

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) Restart

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

func (*Supervisor) Run

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

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