runtime

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 18 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

Overview

Package runtime supervises project-local service processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InheritedEnvironment

func InheritedEnvironment() []string

InheritedEnvironment returns the baseline, so that documentation describing it is built from the same list the runtime uses rather than from a second copy.

func TailnetHostVariable

func TailnetHostVariable() string

TailnetHostVariable is the name grat sets a machine's tailnet host under, so documentation naming it is built from the same constant the runtime uses.

Types

type Manager

type Manager struct {
	Root           string
	Config         config.Config
	ListenerLookup ports.ListenerLookup
	HTTPClient     *http.Client
	Observer       ProgressObserver
	// TailnetHost is this machine's name inside the tailnet, or empty where the
	// machine belongs to none. A development server that checks the Host header
	// needs it to accept a request arriving through a funnel, and only the
	// caller can find it out, so the runtime is told rather than asking.
	TailnetHost string
}

Manager owns state and lifecycle operations for exactly one project root.

func (Manager) LogPath

func (manager Manager) LogPath(name string) (string, error)

LogPath returns the project-local log file for a configured service.

func (Manager) Recover

func (manager Manager) Recover(ctx context.Context, candidates []RecoveryCandidate) error

Recover explicitly adopts only the confirmed V1 candidate snapshot long enough to stop its isolated process groups. It leaves regular lifecycle methods fail-closed.

func (Manager) RecoveryCandidates

func (manager Manager) RecoveryCandidates(names []string) ([]RecoveryCandidate, error)

RecoveryCandidates reports recorded V1 service states that are eligible for explicit recovery. It never changes a state file or signals a process.

func (Manager) Restart

func (manager Manager) Restart(ctx context.Context, names []string) error

Restart stops selected services before starting them with new detached sessions.

func (Manager) Services

func (manager Manager) Services(names []string) ([]config.Service, error)

Services returns the configured services selected by names. An empty name list selects every configured service in declaration order.

func (Manager) Start

func (manager Manager) Start(ctx context.Context, names []string) error

Start launches selected services and waits until each reaches its configured readiness boundary. An empty names list selects all configured services.

func (Manager) Status

func (manager Manager) Status(ctx context.Context) ([]Status, error)

Status observes every configured service and returns an unhealthy state when a recorded process does not own its expected listener or fails HTTP readiness.

func (Manager) Stop

func (manager Manager) Stop(ctx context.Context, names []string) error

Stop terminates selected services. An empty names list selects all configured services. Only validated grat-managed process groups are terminated.

type ProgressEvent

type ProgressEvent struct {
	Service config.Service
	Stage   ProgressStage
	Detail  string
}

ProgressEvent describes one lifecycle transition for a service.

type ProgressObserver

type ProgressObserver interface {
	ObserveProgress(ProgressEvent)
}

ProgressObserver receives ordered lifecycle events from a Manager.

type ProgressObserverFunc

type ProgressObserverFunc func(ProgressEvent)

ProgressObserverFunc adapts a function to ProgressObserver.

func (ProgressObserverFunc) ObserveProgress

func (function ProgressObserverFunc) ObserveProgress(event ProgressEvent)

ObserveProgress delivers event to the wrapped function.

type ProgressStage

type ProgressStage string

ProgressStage identifies an actual lifecycle transition observed by a Manager. Events are emitted once per stage, not on a timer.

const (
	// ProgressInspecting indicates that the manager is reading recorded state.
	ProgressInspecting ProgressStage = "inspecting"
	// ProgressAlreadyReady indicates a selected service was already healthy.
	ProgressAlreadyReady ProgressStage = "already-ready"
	// ProgressAlreadyStopped indicates a selected service had no recorded process.
	ProgressAlreadyStopped ProgressStage = "already-stopped"
	// ProgressStopping indicates graceful process termination has begun.
	ProgressStopping ProgressStage = "stopping"
	// ProgressStopped indicates state removal completed after termination.
	ProgressStopped ProgressStage = "stopped"
	// ProgressLaunching indicates the isolated command process is being started.
	ProgressLaunching ProgressStage = "launching"
	// ProgressWaitingForHealth indicates listener ownership and HTTP readiness
	// are being checked.
	ProgressWaitingForHealth ProgressStage = "waiting-for-health"
	// ProgressReady indicates the full configured readiness boundary passed.
	ProgressReady ProgressStage = "ready"
	// ProgressFailed indicates a lifecycle operation could not complete.
	ProgressFailed ProgressStage = "failed"
)

type RecoveryCandidate

type RecoveryCandidate struct {
	Service      config.Service
	PID          int
	ProcessGroup int
	Command      string
	Live         bool
	// contains filtered or unexported fields
}

RecoveryCandidate is a legacy process state that can be reviewed before explicit recovery. Live candidates have passed the V1 identity validation.

type State

type State string

State describes the observed lifecycle state of one configured service.

const (
	// StateStopped means no live managed process exists.
	StateStopped State = "stopped"
	// StateRunning means the process, listener, and health boundary are ready.
	StateRunning State = "running"
	// StateUnhealthy means a recorded process is live but fails readiness checks.
	StateUnhealthy State = "unhealthy"
)

type Status

type Status struct {
	Service config.Service
	PID     int
	State   State
	URL     string
	Reason  string
}

Status is the rendered-independent observation of one configured service.

Jump to

Keyboard shortcuts

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