process

package
v0.0.0-...-148b1ff Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStartAborted = fmt.Errorf("aborted")

Functions

func SetupTreeCleanup

func SetupTreeCleanup() error

SetupTreeCleanup is a no-op on non-Windows platforms, where upstream process teardown is handled via process-group signalling (see runtime_unix.go).

Types

type Process

type Process interface {
	// Run starts the process blocks until the process is terminated.
	// The timeout parameter controls how long to wait for the process to get
	// to a ready state to process traffic
	Run(timeout time.Duration) error

	// WaitReady blocks until the process is ready to serve requests
	// or the context is cancelled. It returns nil when the process is ready
	WaitReady(context.Context) error

	// Stop blocks until the process has terminated. It returns nil when
	// the process terminated as expected (exit 0)
	Stop(timeout time.Duration) error

	// State returns the current state of the process
	// Note: this is a snapshot of the state at the time of the call
	// and may change at any time after the call returns.
	State() ProcessState

	// ServeHTTP forwards requests to the underlying process
	// Calling it when the process is not ready will result in a
	// 503 response with a body indicating it is a llama-swap-error
	ServeHTTP(http.ResponseWriter, *http.Request)

	// Logger returns the monitor that captures this process's stdout/stderr.
	Logger() *logmon.Monitor
}

type ProcessCommand

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

func New

func New(
	parentCtx context.Context,
	id string,
	conf config.ModelConfig,
	processLogger *logmon.Monitor,
	proxyLogger *logmon.Monitor,
) (*ProcessCommand, error)

func (*ProcessCommand) ID

func (p *ProcessCommand) ID() string

func (*ProcessCommand) Logger

func (p *ProcessCommand) Logger() *logmon.Monitor

func (*ProcessCommand) Run

func (p *ProcessCommand) Run(timeout time.Duration) error

func (*ProcessCommand) ServeHTTP

func (p *ProcessCommand) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ProcessCommand) State

func (p *ProcessCommand) State() ProcessState

func (*ProcessCommand) Stop

func (p *ProcessCommand) Stop(timeout time.Duration) error

func (*ProcessCommand) WaitReady

func (p *ProcessCommand) WaitReady(ctx context.Context) error

type ProcessState

type ProcessState string
const (
	StateStopped  ProcessState = ProcessState("stopped")
	StateStarting ProcessState = ProcessState("starting")
	StateReady    ProcessState = ProcessState("ready")
	StateStopping ProcessState = ProcessState("stopping")

	// process is shutdown and will not be restarted
	StateShutdown ProcessState = ProcessState("shutdown")
)