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 ErrBusy = errors.New("programs are busy")
ErrBusy reports that an owner's programs are all in use.
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) Invalidate ¶
Invalidate kills every program of owner, in use or not.
func (*Pool) Lease ¶
func (pool *Pool) Lease(owner string, rank func(*Entry) int, start func() (*Process, any, error)) (*Entry, error)
Lease returns the idle program of owner that rank values highest above zero, else starts one. At the limit it replaces the owner's longest-idle program; when every one is in use it fails with ErrBusy. 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.