Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd is a wrapper around exec.Cmd that eases syncing to other Cmd's via Group.
Its implementation calls the shell directly (through zsh/bash)
Cmd can indicate that the underlying process has reached a "ready state" by
- Its stdout/stderr outputs matching a given regexp.
- Its underlying process completing/exiting with a non-zero code.
An interrupt signal can be sent to the underlying process via Interrupt().
func (*Cmd) Write ¶
Write implements io.Writer, so that Cmd itself can be used for exec.Cmd.Stdout and Stderr Write "intercepts" writes to Stdout/Stderr to check if the outputs match a regexp and determines if a command has reached its "ready state" the ready state is used by Orchestrator to coordinate dependent commands
type CmdOption ¶
func CmdDir ¶
CmdDir is a functional option that modifies the Dir property of the underlying exec.Cmd which is the directory to execute the Command from
func CmdName ¶
CmdName is a functional option that sets a monitored command's name, which is used to prefix each line written to Stdout
func DependsOn ¶
DependsOn is a functional option that sets a slice of dependencies for this command. The dependencies are names of commands that need to have completed or reached a ready state prior to this command starting.
Note that there is no validation that the cmdNames are valid/match other Cmd's configs (because it would cause a circular dependency). Some, but not all possible config errors are checked at runtime.
func Environment ¶
Environment is a functional option that adds export commands to the start of a command. This is a bit of a hacky workaround to maintain exec.Cmd's default environment, while being able to set additional variables
func ReadyPattern ¶
ReadyPattern is a functional option that takes in a pattern string that must compile into a valid regexp and sets it to monitored command's readyPattern field
func SilenceOutput ¶
func SilenceOutput() CmdOption
SilenceOutput sets the command's Stdout and Stderr to nil so no output will be seen in the terminal
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group manages scheduling concurrent Cmds
func NewGroup ¶
NewGroup makes a new Group it can be optionally initialized with commands or they can be added later via AddCommands
func (*Group) AddCommands ¶
AddCommands will add Cmds to the commands slice It will return an error if called after Group.Run()
func (*Group) Run ¶
Run will run all of the group's Cmds and block until they have all finished running, or an interrupt/kill signal is received, or the context cancels
It checks for each Cmd's prerequisites (Cmds it depends-on being in a ready state) before starting the Cmd
The returned error is the first error returned from the Group's Cmds, if any
func (*Group) SendInterrupts ¶
func (g *Group) SendInterrupts()
SendInterrupts relays an interrupt signal to all underlying commands