runs

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 21 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 runs starts one run's process in a pty the engine owns, supervises it to its end and stops it. A Supervisor holds an engine's live processes in memory. Its start intent writes the run's spec file and starts the bound start command, never a second time for a run; its loop turns the OSC 7501 states the process reports into the run's state and asks the harness for the run's result, which ends the run; its watch timer keeps the engine up while a run has not ended, and ends as error a run whose engine stopped. Every write to a run goes through internal/state/run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Env is the engine's environment, which the bound commands' is made
	// from.
	Env []string
	// State reaches a repo's state by the repo's root. UseState may set it
	// after New; a run started before either is set ends as error.
	State func(ctx context.Context, root string) (*state.State, error)
	// Grace is how long a process has to exit after SIGHUP and SIGTERM
	// before SIGKILL, and how long its output has to end after it exits; 0
	// means 5 seconds.
	Grace time.Duration
	// ResultTimeout and StopTimeout are the deadlines of the bound result
	// and stop commands; 0 means 2 minutes and 30 seconds.
	ResultTimeout, StopTimeout time.Duration
}

Options configures a Supervisor.

type StopIn

type StopIn struct {
	Run                      int64
	By, Store, Root, StopCmd string
}

StopIn stops a run, saying who stopped it. Store is the repo's store directory, which with the run names the process the supervisor holds; Root is only the directory a command runs in. StopCmd is the bound stop line to run when the supervisor holds no process for the run: a run it holds is stopped with the stop line it was started with.

type Supervisor

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

Supervisor holds the live processes of one engine's runs, in memory. Its kinds start a run's process and watch the run; Stop ends one; Close ends them all.

func New

func New(o Options) *Supervisor

New returns a Supervisor that holds no run.

func (*Supervisor) Close

func (s *Supervisor) Close()

Close ends every process the supervisor holds and cuts every result and stop command in flight, then waits for every goroutine it owns. It writes nothing to the store: the next engine's watch timer ends those runs as error. A run whose start is carried out after Close starts no process.

func (*Supervisor) Kinds

func (s *Supervisor) Kinds() ([]state.TimerKind, []state.IntentKind)

Kinds returns the two kinds a started run needs, for the state's options: the watch timer and the start intent.

func (*Supervisor) Stop

func (s *Supervisor) Stop(ctx context.Context, st *state.State, in StopIn) (staterun.Run, error)

Stop ends a run as stopped by in.By and returns it. A run that has already ended is refused, naming how it ended, and so is an empty By; nothing is run for either. For a run the supervisor holds it cuts a result command in flight, runs the stop line the run was started with, ends the process and waits for it; for one that is still starting it makes the start start nothing; for any other it runs in.StopCmd. Then it records the stop and removes the run's directory.

Once the run is known not to have ended, Stop finishes whatever happens to ctx: it works on a context of its own, bounded by StopTimeout plus twice Grace, so a caller that gives up never leaves an ended process with no record of who stopped it.

func (*Supervisor) UseState

func (s *Supervisor) UseState(get func(ctx context.Context, root string) (*state.State, error))

UseState sets how the supervisor reaches a repo's state, for an engine that can only say so once it is built.

Jump to

Keyboard shortcuts

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