subprocess

package
v0.12.10 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthCheck

type HealthCheck struct {
	URL      string        // e.g. "https://127.0.0.1:4444/health/alive"
	Interval time.Duration // polling interval
	Timeout  time.Duration // overall timeout before giving up
	TLS      *tls.Config   // optional TLS config for HTTPS health endpoints
}

HealthCheck defines how to check if a subprocess is healthy.

type ManagedSubprocess

type ManagedSubprocess struct {
	Name string
	Cmd  *exec.Cmd
	// contains filtered or unexported fields
}

ManagedSubprocess tracks a running subprocess.

type SubprocessManager

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

SubprocessManager starts, monitors, and shuts down a set of subprocesses. Fail-fast: if any subprocess exits unexpectedly, the crash is reported via CrashChan. Once Shutdown begins, subsequent subprocess exits are expected and are NOT reported as crashes. Shutdown is reverse order of start.

func NewSubprocessManager

func NewSubprocessManager(log *logger.Logger) *SubprocessManager

NewSubprocessManager creates a new subprocess manager.

func (*SubprocessManager) BeginShutdown

func (m *SubprocessManager) BeginShutdown()

BeginShutdown marks the manager as shutting down, suppressing crash reporting for any subprocess that exits from this point forward. Call this as early as possible in the shutdown sequence — before stopping servers or other components that may cause cascading subprocess exits. Shutdown() also sets this flag, but calling BeginShutdown early closes the window between signal receipt and Shutdown() invocation.

func (*SubprocessManager) CrashChan

func (m *SubprocessManager) CrashChan() <-chan error

CrashChan returns a channel that receives an error when any managed subprocess exits unexpectedly. The CP main loop selects on this alongside signal handling.

func (*SubprocessManager) ForwardSignal

func (m *SubprocessManager) ForwardSignal(sig os.Signal)

ForwardSignal sends the given signal to all managed subprocesses.

func (*SubprocessManager) Shutdown

func (m *SubprocessManager) Shutdown(timeout time.Duration)

Shutdown sends SIGTERM to all subprocesses in reverse start order, waits up to timeout for each to exit, then sends SIGKILL if needed. Sets the shuttingDown flag if BeginShutdown was not already called.

func (*SubprocessManager) Start

func (m *SubprocessManager) Start(name string, cmd *exec.Cmd) error

Start launches a subprocess and begins monitoring its PID. Stdout/stderr are forwarded to the CP's stderr (visible in docker logs).

func (*SubprocessManager) WaitHealthy

func (m *SubprocessManager) WaitHealthy(ctx context.Context, name string, check HealthCheck) error

WaitHealthy polls a health endpoint until it returns 200 or the timeout expires. Returns an error if the subprocess crashes before becoming healthy.

Jump to

Keyboard shortcuts

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