Documentation
¶
Overview ¶
Package program starts and owns the executables a package declares. It knows no protocol: a caller receives the child's standard streams and speaks whatever the program speaks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotInstalled = errors.New("program is not installed")
ErrNotInstalled reports that the command is not on the search path.
Functions ¶
func Resolve ¶
Resolve finds an executable by name on the PATH of environment. A name with a separator is refused, so a declaration never names a path.
func StartGroup ¶
StartGroup starts command as the leader of its own process group (a job object on Windows) and returns the function that kills the whole group.
Types ¶
type File ¶
type File struct{ Path, Content string }
File is written into the program's directory before it starts.
type Pool ¶
Pool bounds and reaps the running programs of every owner (a package). A caller attaches its own protocol state to an entry as Value.
func (*Pool) Each ¶
Each calls visit with every running program of owner that takes leases, in use or not. visit synchronizes its own access to a shared Value.
func (*Pool) Invalidate ¶
Invalidate kills every program of owner, in use or not.
func (*Pool) Lease ¶
func (pool *Pool) Lease(ctx context.Context, owner string, shares int, rank func(*Entry) int, start func() (*Process, any, error)) (*Entry, error)
Lease returns the program of owner that rank values highest above zero among those serving fewer than shares requests, else starts one. At the pool's Limit it replaces the owner's longest-idle program; when none is idle it waits for a release until ctx ends. shares below one means one. Callers hold an entry for one request, so a wait ends when one finishes. The caller must Release the entry.
type Process ¶
type Process struct {
Stdin io.WriteCloser
Stdout io.Reader
// contains filtered or unexported fields
}
Process is a running program with piped standard streams. A program that needs a terminal instead of pipes is not built: it would be a second start function here returning the same Process over the PTY that internal/node/terminal owns, with Pool unchanged.
func Start ¶
Start writes the declared files, then runs the program in its directory with a scrubbed environment, as the leader of its own process group. Its standard error goes to the Node's log line by line.
func (*Process) Diagnostic ¶
Diagnostic is the last line the program wrote to standard error.
type Spec ¶
type Spec struct {
Command string
Args []string
Env map[string]string
Files []File
Dir string
// Host is the Node's environment as NAME=value entries.
Host []string
// Log names the program in the Node's diagnostics.
Log string
}
Spec is one start of a declared program. Dir is the program's own directory: its working directory and the only place Files are written.