appsupervisor

package
v0.85.0-pre.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package appsupervisor manages dev-server process lifecycle and readiness probing.

It exists to keep process control and health-check policy separate from higher-level watcher and hook orchestration code.

Index

Constants

View Source
const (
	// DefaultAppProcessGracefulStopTimeout is the default timeout for process stop.
	DefaultAppProcessGracefulStopTimeout = 6 * time.Second
	// LocalReadinessProbeHostIPv4 is the default host used for probe URL generation.
	LocalReadinessProbeHostIPv4 = "127.0.0.1"
	// LocalReadinessProbeHostLocalhost is alternate host used for probe fallback.
	LocalReadinessProbeHostLocalhost = "localhost"
)

Variables

This section is empty.

Functions

func DeriveReadinessWaitDelay

func DeriveReadinessWaitDelay(
	attemptIndex int,
	baseDelay time.Duration,
	maximumDelay time.Duration,
) time.Duration

DeriveReadinessWaitDelay computes delay using capped doubling backoff.

func ResolveAppReadyURL

func ResolveAppReadyURL(appPort int, healthcheckEndpoint string) string

ResolveAppReadyURL resolves app healthcheck URL for given runtime port.

func ResolveReadinessProbeURL

func ResolveReadinessProbeURL(host string, port int, endpoint string) string

ResolveReadinessProbeURL builds a readiness URL from host/port/endpoint.

func ShouldContinueReadinessWait

func ShouldContinueReadinessWait(
	totalElapsed time.Duration,
	maximumTotal time.Duration,
) bool

ShouldContinueReadinessWait reports whether elapsed time is still within budget.

func ShouldIgnoreProcessTerminationError

func ShouldIgnoreProcessTerminationError(processTerminationError error) bool

ShouldIgnoreProcessTerminationError reports expected stop outcomes.

func ShouldIgnoreProcessWaitError

func ShouldIgnoreProcessWaitError(processWaitError error) bool

ShouldIgnoreProcessWaitError reports expected wait outcomes from termination.

func WaitForAnyReady

func WaitForAnyReady(urls []string, policy ReadinessWaitPolicy) bool

WaitForAnyReady polls URLs until one is healthy or timeout budget expires.

func WaitForAnyReadyWithContext

func WaitForAnyReadyWithContext(
	readinessContext context.Context,
	urls []string,
	policy ReadinessWaitPolicy,
) bool

WaitForAnyReadyWithContext polls URLs until one is healthy, timeout budget expires, or context cancellation is observed.

Types

type AppProcessManager

type AppProcessManager struct {
	GracefulStopTimeout time.Duration
	// contains filtered or unexported fields
}

AppProcessManager owns lifecycle operations for the app runtime process.

func NewAppProcessManager

func NewAppProcessManager() *AppProcessManager

NewAppProcessManager creates a new process manager.

func (*AppProcessManager) CurrentCommand

func (processManager *AppProcessManager) CurrentCommand() *exec.Cmd

CurrentCommand returns the current tracked command pointer.

func (*AppProcessManager) StartApp

func (processManager *AppProcessManager) StartApp(
	binaryPath string,
) (*exec.Cmd, error)

StartApp starts a new app process and records it as current command.

func (*AppProcessManager) StopApp

func (processManager *AppProcessManager) StopApp(command *exec.Cmd) error

StopApp stops the provided command when it matches current running app.

func (*AppProcessManager) StopCurrentApp

func (processManager *AppProcessManager) StopCurrentApp() error

StopCurrentApp stops the currently tracked app process.

type ReadinessWaitPolicy

type ReadinessWaitPolicy struct {
	HTTPClientTimeout          time.Duration
	InitialDelay               time.Duration
	MaximumDelay               time.Duration
	MaximumTotalWait           time.Duration
	TreatHTTPStatusCodeAsReady func(int) bool
}

ReadinessWaitPolicy defines polling behavior for readiness checks.

func DefaultReadinessWaitPolicy

func DefaultReadinessWaitPolicy() ReadinessWaitPolicy

DefaultReadinessWaitPolicy returns robust defaults for local dev readiness polling.

Jump to

Keyboard shortcuts

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