sentinel

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GracePeriod is the time to wait after SIGTERM before sending SIGKILL.
	GracePeriod = 10 * time.Second

	// InitialBackoff is the initial delay before restarting after an abnormal exit.
	InitialBackoff = 5 * time.Second

	// MaxBackoff is the maximum delay between restarts.
	MaxBackoff = 10 * time.Minute

	// BackoffFactor is the multiplier for each successive backoff.
	BackoffFactor = 2.0

	// SuccessRunTime is how long the child must run before backoff resets.
	SuccessRunTime = 30 * time.Second

	// DebounceInterval is the delay after an fsnotify event before checking the checksum.
	DebounceInterval = 100 * time.Millisecond

	// ScriptWaitTimeout is the maximum time to wait for the child to finish
	// running scripts after SIGUSR1 before falling back to SIGTERM+SIGKILL.
	// The script execution timeout is 5 minutes, so 6 minutes provides buffer.
	ScriptWaitTimeout = 6 * time.Minute
)

Variables

This section is empty.

Functions

func HashFile

func HashFile(path string) ([sha256.Size]byte, error)

HashFile computes the SHA256 hash of the file at the given path.

func Run

func Run(extraArgs ...string)

Run starts the sentinel supervisor loop. It resolves the current executable path, starts a child process with the "run" subcommand, watches the binary for changes, and restarts the child on crash with exponential backoff. Any extra arguments are appended to the child's "run" command (e.g. "--prof"). This function blocks until SIGINT/SIGTERM is received.

Types

type Sentinel

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

Sentinel manages the lifecycle of a child process with the "run" subcommand.

Jump to

Keyboard shortcuts

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