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 ¶
- type Options
- type StopIn
- type Supervisor
- func (s *Supervisor) Close()
- func (s *Supervisor) Kinds() ([]state.TimerKind, []state.IntentKind)
- func (s *Supervisor) Live(except string) int
- func (s *Supervisor) Stop(ctx context.Context, st *state.State, in StopIn) (staterun.Run, error)
- func (s *Supervisor) UseState(get func(ctx context.Context, root string) (*state.State, error))
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 ¶
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 (*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) Live ¶ added in v0.0.57
func (s *Supervisor) Live(except string) int
Live returns how many runs the supervisor holds, starting or live, for store directories other than except: the runs of the other repos the engine has open. It follows the lock order of Supervisor.mu: it takes only the table lock, for the map read, so a state's loop may call it inside a transaction.
func (*Supervisor) Stop ¶
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package spec writes a run's spec file: the pursuit, the change and the text of the map's slice for the change's capability, which the run's process reads to know what to build.
|
Package spec writes a run's spec file: the pursuit, the change and the text of the map's slice for the change's capability, which the run's process reads to know what to build. |