Documentation
¶
Index ¶
- Variables
- func IsCmdRunning(cmd *exec.Cmd) bool
- func IsCmdRunningHandler(cmd *exec.Cmd) error
- type Cmd
- func (c *Cmd) CombinedOutput() ([]byte, error)
- func (c *Cmd) CombinedOutputClosure() func(...string) ([]byte, error)
- func (c *Cmd) Command() *exec.Cmd
- func (c *Cmd) Output() ([]byte, error)
- func (c *Cmd) OutputClosure() func(...string) ([]byte, error)
- func (c *Cmd) Pipe(name string, args ...string) *Cmd
- func (c *Cmd) ReadStderr() ([]byte, error)
- func (c *Cmd) ReadStdout() ([]byte, error)
- func (c *Cmd) Run() error
- func (c *Cmd) RunForever(startup *Probe) error
- func (c *Cmd) SetCmdMutator(f func(name string, args []string) (string, []string))
- func (c *Cmd) SetIO(in io.Reader, out, err io.Writer)
- func (c *Cmd) Start() error
- func (c *Cmd) Wait() error
- type Probe
- type ProbeError
Constants ¶
This section is empty.
Variables ¶
var (
ErrExitedInRunForever = errors.New("exec: command should not exit in RunForever")
)
Functions ¶
func IsCmdRunning ¶
func IsCmdRunningHandler ¶
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd represents an external command being prepared or run basically. It also can combine several existing Command into a pipeline, just like running in shell: echo "3\n2\n1" | sort
A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods.
func CommandContext ¶
Standard CommandContext api follow os/exec.CommandContext
func (*Cmd) CombinedOutput ¶
CombinedOutput runs the command and returns its combined standard output and standard error.
func (*Cmd) CombinedOutputClosure ¶
CombinedOutputClosure returns function closure allowing you to call this command latter. The closure runs the command and reads all bytes from combined standard output and standard error
func (*Cmd) Output ¶
Output runs the command and returns its standard output. Any returned error will usually be of type *ExitError.
func (*Cmd) OutputClosure ¶
OutputClosure returns a function closure allowing you to call this command latter. The closure runs the command and reads all bytes from standard output
echo := Command("echo").OutputClosure() echo("123") echo("321")
func (*Cmd) Pipe ¶
Pipe creates a new command with given args and connects this command's standard output to new command's standard input
func (*Cmd) ReadStderr ¶
ReadStderr reads all bytes from command's standard error The command must have been finished by Wait.
func (*Cmd) ReadStdout ¶
ReadStdout reads all bytes from command's standard output The command must have been finished by Wait.
func (*Cmd) Run ¶
Run starts the specified command and waits for it to complete.
The returned error is nil if the command runs, you can safely get output from Stdout() or error message from Stderr()
If the command starts but does not complete successfully, the error is of type *ExitError. Other error types may be returned for other situations.
If the calling goroutine has locked the operating system thread with runtime.LockOSThread and modified any inheritable OS-level thread state (for example, Linux or Plan 9 name spaces), the new process will inherit the caller's thread state./
func (*Cmd) RunForever ¶
func (*Cmd) SetCmdMutator ¶
SetCmdMutator set a mutator function to mutator the runtime command's name and args
func (*Cmd) Start ¶
Start starts the specified command but does not wait for it to complete.
The Wait method will return the exit code and release associated resources once the command exits.
func (*Cmd) Wait ¶
Wait waits for the command to exit and waits for any copying to stdin or copying from stdout or stderr to complete.
The command must have been started by Start.
The returned error is nil if the command runs, you can safely get output from Stdout() or error message from Stderr()
If the command fails to run or doesn't complete successfully, the error is of type *ExitError. Other error types may be returned for I/O problems.
If any of c.Stdin, c.Stdout or c.Stderr are not an *os.File, Wait also waits for the respective I/O loop copying to or from the process to complete.
Wait releases any resources associated with the Cmd.
type Probe ¶
type Probe struct {
// The action taken to determine the health of a cmd
// Default to IsCmdRunningHandler
Handler func(running *exec.Cmd) error `json:"handler,inline" protobuf:"bytes,1,opt,name=handler"`
// Number of seconds after the container has started before liveness probes are initiated.
// +optional
InitialDelaySeconds int `json:"initialDelaySeconds,omitempty" protobuf:"varint,2,opt,name=initialDelaySeconds"`
// How often (in seconds) to perform the probe.
// Default to 1 seconds. Minimum value is 1.
// +optional
PeriodSeconds int `json:"periodSeconds,omitempty" protobuf:"varint,4,opt,name=periodSeconds"`
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Defaults to 2. Must be 1 for liveness. Minimum value is 1.
// +optional
SuccessThreshold int `json:"successThreshold,omitempty" protobuf:"varint,5,opt,name=successThreshold"`
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
// Defaults to 3. Minimum value is 1.
// +optional
FailureThreshold int `json:"failureThreshold,omitempty" protobuf:"varint,6,opt,name=failureThreshold"`
}
Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.
type ProbeError ¶
type ProbeError struct {
// contains filtered or unexported fields
}
func (*ProbeError) Error ¶
func (e *ProbeError) Error() string