execctl

package
v0.0.0-...-b7a57f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCmdAlreadyStarted = errors.New("cmd already started")
)

Functions

func NewCmdTree

func NewCmdTree(root *Cmd, subcommands ...*Cmd) *cmdTree

Types

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

Cmd allows to control a process started through os.Exec with additional start, stop and restart capabilities, and provides readers/writers for the command's outputs and input, respectively.

func NewCmd

func NewCmd(name string, exe string, opts ...Option) (c *Cmd, err error)

NewCmd creates a new Cmd, ready to be started

func (*Cmd) Done

func (c *Cmd) Done() <-chan struct{}

func (*Cmd) Name

func (c *Cmd) Name() string

func (*Cmd) Restart

func (c *Cmd) Restart() error

Restart first interrupts the command if it's already running, and then re-runs the command.

func (*Cmd) Running

func (c *Cmd) Running() bool

func (*Cmd) Shutdown

func (c *Cmd) Shutdown() error

Shutdown stops the cmd

func (*Cmd) Start

func (c *Cmd) Start() error

Start starts the command if it's not already running. It will be a noop if it is. It also spins up a goroutine that will receive any error occurred during the command's exit.

func (*Cmd) Stderr

func (c *Cmd) Stderr() io.Reader

Stderr returns a reader to the command's stderr. The reader will return an io.EOF error if the command exits.

func (*Cmd) Stdin

func (c *Cmd) Stdin() io.Writer

Stdin returns a writer to the command's stdin. The writer will be closed if the command has exited by the time this function is called.

func (*Cmd) Stdout

func (c *Cmd) Stdout() io.Reader

Stdout returns a reader to the command's stdout. The reader will return an io.EOF error if the command exits.

func (*Cmd) Stop

func (c *Cmd) Stop() error

Stop stops the running command with an os.Interrupt signal. It does not return an error if the command has already exited gracefully.

func (*Cmd) Wait

func (c *Cmd) Wait() error

Wait awaits for the command to stop running (either to gracefully exit or be interrupted). If the command has already finished when Wait is invoked, it returns the error that was returned when the command exited, if any.

type Option

type Option func(c *Cmd)

func WithArgs

func WithArgs(args ...string) Option

func WithEnv

func WithEnv(env []string) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL