command

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitEnv = []string{

	"LANG=en_US.UTF-8",
}

GitEnv contains the ENV variables for git commands

View Source
var SetupStdin io.Reader = stdinSentinel{}

SetupStdin instructs New() to configure the stdin pipe of the command it is creating. This allows you call Write() on the command as if it is an ordinary io.Writer, sending data directly to the stdin of the process.

You should not call Read() on this value - it is strictly for configuration!

Functions

func ExitStatus

func ExitStatus(err error) (int, bool)

ExitStatus will return the exit-code from an error returned by Wait().

func GitPath

func GitPath() string

GitPath returns the path to the `git` binary. See `SetGitPath` for details on how this is set

func WaitAllDone added in v0.40.0

func WaitAllDone()

WaitAllDone waits for all commands started by the command package to finish. This can only be called once in the lifecycle of the current Go process.

Types

type Command

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

Command encapsulates a running exec.Cmd. The embedded exec.Cmd is terminated and reaped automatically when the context.Context that created it is canceled.

func New

func New(ctx context.Context, cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.Writer, env ...string) (*Command, error)

New creates a Command from an exec.Cmd. On success, the Command contains a running subprocess. When ctx is canceled the embedded process will be terminated and reaped automatically.

If stdin is specified as SetupStdin, you will be able to write to the stdin of the subprocess by calling Write() on the returned Command.

func (*Command) Read added in v0.40.0

func (c *Command) Read(p []byte) (int, error)

Read calls Read() on the stdout pipe of the command.

func (*Command) Wait added in v0.40.0

func (c *Command) Wait() error

Wait calls Wait() on the exec.Cmd instance inside the command. This blocks until the command has finished and reports the command exit status via the error return value. Use ExitStatus to get the integer exit status from the error returned by Wait().

func (*Command) Write added in v1.7.0

func (c *Command) Write(p []byte) (int, error)

Write calls Write() on the stdin pipe of the command.

type SpawnConfig added in v0.61.0

type SpawnConfig struct {
	// This default value (10 seconds) is very high. Spawning should take
	// milliseconds or less. If we hit 10 seconds, something is wrong, and
	// failing the request will create breathing room. Can be modified at
	// runtime with the GITALY_COMMAND_SPAWN_TIMEOUT environment variable.
	Timeout time.Duration `split_words:"true" default:"10s"`

	// MaxSpawnParallel limits the number of goroutines that can spawn a
	// process at the same time. These parallel spawns will contend for a
	// single lock (syscall.ForkLock) in exec.Cmd.Start(). Can be modified at
	// runtime with the GITALY_COMMAND_SPAWN_MAX_PARALLEL variable.
	//
	// Note that this does not limit the total number of child processes that
	// can be attached to Gitaly at the same time. It only limits the rate at
	// which we can create new child processes.
	MaxParallel int `split_words:"true" default:"10"`
}

SpawnConfig holds configuration for command spawning timeouts and parallelism.

Jump to

Keyboard shortcuts

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