{"modulePath":"github.com/flant/shell-operator","version":"v1.21.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package executor\n\n## Functions\n\n```go\nfunc Run(cmd *exec.Cmd) error\n```\nRun starts the command, waits for it to complete, and returns the error. The child PID is registered in the global process registry while the process is running so that a PID-1 zombie reaper does not steal it.\n\n## Types\n\n```go\ntype CmdUsage struct {\n\tSys    time.Duration\n\tUser   time.Duration\n\tMaxRss int64\n}\n```\n\n```go\ntype Executor struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewExecutor(dir string, entrypoint string, args []string, envs []string) *Executor\n```\n\n```go\nfunc (e *Executor) Output() ([]byte, error)\n```\n\n```go\nfunc (e *Executor) RunAndLogLines(ctx context.Context, logLabels map[string]string) (*CmdUsage, error)\n```\n\n```go\nfunc (e *Executor) WithCMDStderr(w io.Writer) *Executor\n```\n\n```go\nfunc (e *Executor) WithCMDStdout(w io.Writer) *Executor\n```\n\n```go\nfunc (e *Executor) WithChroot(path string) *Executor\n```\n\n```go\nfunc (e *Executor) WithLogProxyHookJSON(logProxyHookJSON bool) *Executor\n```\n\n```go\nfunc (e *Executor) WithLogProxyHookJSONKey(logProxyHookJSONKey string) *Executor\n```\n\n```go\nfunc (e *Executor) WithLogger(logger *log.Logger) *Executor\n```\n\n```go\nfunc (e *Executor) WithRunner(runner Runner) *Executor\n```\nWithRunner sets how RunAndLogLines runs the command. A nil runner keeps ProcessRunner. Output, used for the --config call, always starts a process.\n\n```go\ntype ProcessRunner struct{}\n```\nProcessRunner runs a hook command as a child process. The context is not used to stop the process: a hook runs to completion, as it always has.\n\n```go\nfunc (ProcessRunner) Run(_ context.Context, cmd *exec.Cmd) (*CmdUsage, error)\n```\n\n```go\ntype ProcessTracker interface {\n\t// IsActive reports whether pid is currently tracked as a running process.\n\tIsActive(pid int) bool\n}\n```\nProcessTracker is a read-only view into the process registry. It is intended for consumers (such as a PID-1 zombie reaper) that need to check whether a PID is managed by the executor but must not modify the registry.\n\n```go\nfunc Tracker() ProcessTracker\n```\nTracker returns a read-only view of the global process registry. The zombie reaper should call this once and use the returned ProcessTracker to check whether a PID is managed by the executor.\n\n```go\ntype Runner interface {\n\tRun(ctx context.Context, cmd *exec.Cmd) (*CmdUsage, error)\n}\n```\nRunner starts a prepared hook command and waits for it to finish.\n\ncmd carries what the hook is run with: Path, Args, Env, Dir, and the writers its stdout and stderr go to. A Runner must leave the other fields alone. Run returns an error when the hook could not be run or exited with a non-zero code; whatever the hook wrote to stderr is turned into a StderrError by the caller.\n\nProcessRunner, the default, starts cmd as a child process. An application embedding shell-operator may supply its own Runner, for example one that hands the command to a long-lived interpreter instead of starting a fresh one for every event, and fall back to ProcessRunner for the rest.\n\n```go\ntype StderrError struct {\n\tMessage string\n}\n```\nStderrError is returned by RunAndLogLines when a command fails and produces output on stderr. Callers can use errors.As to access the raw stderr content.\n\n```go\nfunc (e *StderrError) Error() string\n```\n\n","path":"github.com/flant/shell-operator/pkg/executor","name":"executor","synopsis":"","isRedistributable":true}
