{"modulePath":"github.com/bigcommerce/nomad","version":"v0.9.3-bc","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package executor\n\n## Constants\n\n```go\nconst (\n\t// ExecutorVersionLatest is the current and latest version of the executor\n\tExecutorVersionLatest = \"2.0.0\"\n\n\t// ExecutorVersionPre0_9 is the version of executor use prior to the release\n\t// of 0.9.x\n\tExecutorVersionPre0_9 = \"1.1.0\"\n)\n```\n\n```go\nconst (\n\t// ExecutorDefaultMaxPort is the default max port used by the executor for\n\t// searching for an available port\n\tExecutorDefaultMaxPort = 14512\n\n\t// ExecutorDefaultMinPort is the default min port used by the executor for\n\t// searching for an available port\n\tExecutorDefaultMinPort = 14000\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// The statistics the basic executor exposes\n\tExecutorBasicMeasuredMemStats = []string{\"RSS\", \"Swap\"}\n\tExecutorBasicMeasuredCpuStats = []string{\"System Mode\", \"User Mode\", \"Percent\"}\n)\n```\n\n```go\nvar (\n\t// ExecutorCgroupMeasuredMemStats is the list of memory stats captured by the executor\n\tExecutorCgroupMeasuredMemStats = []string{\"RSS\", \"Cache\", \"Swap\", \"Usage\", \"Max Usage\", \"Kernel Usage\", \"Kernel Max Usage\"}\n\n\t// ExecutorCgroupMeasuredCpuStats is the list of CPU stats captures by the executor\n\tExecutorCgroupMeasuredCpuStats = []string{\"System Mode\", \"User Mode\", \"Throttled Periods\", \"Throttled Time\", \"Percent\"}\n)\n```\n\n## Functions\n\n```go\nfunc DestroyCgroup(groups *lconfigs.Cgroup, executorPid int) error\n```\nDestroyCgroup kills all processes in the cgroup and removes the cgroup configuration from the host. This function is idempotent.\n\n```go\nfunc ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.SysProcAttr,\n\tname string, args []string) ([]byte, int, error)\n```\nExecScript executes cmd with args and returns the output, exit code, and error. Output is truncated to drivers/shared/structs.CheckBufSize\n\n```go\nfunc GetPluginMap(logger hclog.Logger, fsIsolation bool) map[string]plugin.Plugin\n```\n\n```go\nfunc GetPre09PluginMap(logger hclog.Logger, fsIsolation bool) map[string]plugin.Plugin\n```\n\n```go\nfunc JoinRootCgroup(subsystems []string) error\n```\nJoinRootCgroup moves the current process to the cgroups of the init process\n\n## Types\n\n```go\ntype ExecCommand struct {\n\t// Cmd is the command that the user wants to run.\n\tCmd string\n\n\t// Args is the args of the command that the user wants to run.\n\tArgs []string\n\n\t// Resources defined by the task\n\tResources *drivers.Resources\n\n\t// StdoutPath is the path the process stdout should be written to\n\tStdoutPath string\n\n\t// StderrPath is the path the process stderr should be written to\n\tStderrPath string\n\n\t// Env is the list of KEY=val pairs of environment variables to be set\n\tEnv []string\n\n\t// User is the user which the executor uses to run the command.\n\tUser string\n\n\t// TaskDir is the directory path on the host where for the task\n\tTaskDir string\n\n\t// ResourceLimits determines whether resource limits are enforced by the\n\t// executor.\n\tResourceLimits bool\n\n\t// Cgroup marks whether we put the process in a cgroup. Setting this field\n\t// doesn't enforce resource limits. To enforce limits, set ResourceLimits.\n\t// Using the cgroup does allow more precise cleanup of processes.\n\tBasicProcessCgroup bool\n\n\t// Mounts are the host paths to be be made available inside rootfs\n\tMounts []*drivers.MountConfig\n\n\t// Devices are the the device nodes to be created in isolation environment\n\tDevices []*drivers.DeviceConfig\n\t// contains filtered or unexported fields\n}\n```\nExecCommand holds the user command, args, and other isolation related settings.\n\n```go\nfunc (c *ExecCommand) Close()\n```\n\n```go\nfunc (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser)\n```\nGetWriters returns the unexported io.WriteCloser for the stdout and stderr handles. This is mainly used for unit testing purposes.\n\n```go\nfunc (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser)\n```\nSetWriters sets the writer for the process stdout and stderr. This should not be used if writing to a file path such as a fifo file. SetStdoutWriter is mainly used for unit testing purposes.\n\n```go\nfunc (c *ExecCommand) Stderr() (io.WriteCloser, error)\n```\nStderr returns a writer for the configured file descriptor\n\n```go\nfunc (c *ExecCommand) Stdout() (io.WriteCloser, error)\n```\nStdout returns a writer for the configured file descriptor\n\n```go\ntype Executor interface {\n\t// Launch a user process configured by the given ExecCommand\n\tLaunch(launchCmd *ExecCommand) (*ProcessState, error)\n\n\t// Wait blocks until the process exits or an error occures\n\tWait(ctx context.Context) (*ProcessState, error)\n\n\t// Shutdown will shutdown the executor by stopping the user process,\n\t// cleaning up and resources created by the executor. The shutdown sequence\n\t// will first send the given signal to the process. This defaults to \"SIGINT\"\n\t// if not specified. The executor will then wait for the process to exit\n\t// before cleaning up other resources. If the executor waits longer than the\n\t// given grace period, the process is forcefully killed.\n\t//\n\t// To force kill the user process, gracePeriod can be set to 0.\n\tShutdown(signal string, gracePeriod time.Duration) error\n\n\t// UpdateResources updates any resource isolation enforcement with new\n\t// constraints if supported.\n\tUpdateResources(*drivers.Resources) error\n\n\t// Version returns the executor API version\n\tVersion() (*ExecutorVersion, error)\n\n\t// Returns a channel of stats. Stats are collected and\n\t// pushed to the channel on the given interval\n\tStats(context.Context, time.Duration) (\u003c-chan *cstructs.TaskResourceUsage, error)\n\n\t// Signal sends the given signal to the user process\n\tSignal(os.Signal) error\n\n\t// Exec executes the given command and args inside the executor context\n\t// and returns the output and exit code.\n\tExec(deadline time.Time, cmd string, args []string) ([]byte, int, error)\n\n\tExecStreaming(ctx context.Context, cmd []string, tty bool,\n\t\tstream drivers.ExecTaskStream) error\n}\n```\nExecutor is the interface which allows a driver to launch and supervise a process\n\n```go\nfunc CreateExecutor(logger hclog.Logger, driverConfig *base.ClientDriverConfig,\n\texecutorConfig *ExecutorConfig) (Executor, *plugin.Client, error)\n```\nCreateExecutor launches an executor plugin and returns an instance of the Executor interface\n\n```go\nfunc NewExecutor(logger hclog.Logger) Executor\n```\nNewExecutor returns an Executor\n\n```go\nfunc NewExecutorWithIsolation(logger hclog.Logger) Executor\n```\n\n```go\nfunc ReattachToExecutor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error)\n```\nReattachToExecutor launches a plugin with a given plugin config\n\n```go\nfunc ReattachToPre09Executor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error)\n```\nReattachToPre09Executor creates a plugin client that reattaches to an existing pre 0.9 Nomad executor\n\n```go\ntype ExecutorConfig struct {\n\n\t// LogFile is the file to which Executor logs\n\tLogFile string\n\n\t// LogLevel is the level of the logs to putout\n\tLogLevel string\n\n\t// FSIsolation if set will use an executor implementation that support\n\t// filesystem isolation\n\tFSIsolation bool\n}\n```\nExecutorConfig is the config that Nomad passes to the executor\n\n```go\ntype ExecutorPlugin struct {\n\t// TODO: support backwards compatibility with pre 0.9 NetRPC plugin\n\tplugin.NetRPCUnsupportedPlugin\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)\n```\n\n```go\nfunc (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error\n```\n\n```go\ntype ExecutorVersion struct {\n\tVersion string\n}\n```\nExecutorVersion is the version of the executor\n\n```go\nfunc (v *ExecutorVersion) GoString() string\n```\n\n```go\ntype LibcontainerExecutor struct {\n\t// contains filtered or unexported fields\n}\n```\nLibcontainerExecutor implements an Executor with the runc/libcontainer api\n\n```go\nfunc (l *LibcontainerExecutor) Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error)\n```\nExec starts an additional process inside the container\n\n```go\nfunc (l *LibcontainerExecutor) ExecStreaming(ctx context.Context, cmd []string, tty bool,\n\tstream drivers.ExecTaskStream) error\n```\n\n```go\nfunc (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, error)\n```\nLaunch creates a new container in libcontainer and starts a new process with it\n\n```go\nfunc (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) error\n```\nShutdown stops all processes started and cleans up any resources created (such as mountpoints, devices, etc).\n\n```go\nfunc (l *LibcontainerExecutor) Signal(s os.Signal) error\n```\nSignal sends a signal to the process managed by the executor\n\n```go\nfunc (l *LibcontainerExecutor) Stats(ctx context.Context, interval time.Duration) (\u003c-chan *cstructs.TaskResourceUsage, error)\n```\nStats returns the resource statistics for processes managed by the executor\n\n```go\nfunc (l *LibcontainerExecutor) UpdateResources(resources *drivers.Resources) error\n```\nUpdateResources updates the resource isolation with new values to be enforced\n\n```go\nfunc (l *LibcontainerExecutor) Version() (*ExecutorVersion, error)\n```\nVersion returns the api version of the executor\n\n```go\nfunc (l *LibcontainerExecutor) Wait(ctx context.Context) (*ProcessState, error)\n```\nWait waits until a process has exited and returns it's exitcode and errors\n\n```go\ntype PluginReattachConfig struct {\n\tPid      int\n\tAddrNet  string\n\tAddrName string\n}\n```\nExecutorReattachConfig is the config that we serialize and de-serialize and store in disk\n\n```go\nfunc NewPluginReattachConfig(c *plugin.ReattachConfig) *PluginReattachConfig\n```\n\n```go\nfunc (c *PluginReattachConfig) PluginConfig() *plugin.ReattachConfig\n```\nPluginConfig returns a config from an ExecutorReattachConfig\n\n```go\ntype ProcessState struct {\n\tPid      int\n\tExitCode int\n\tSignal   int\n\tTime     time.Time\n}\n```\nProcessState holds information about the state of a user process.\n\n```go\ntype UniversalExecutor struct {\n\t// contains filtered or unexported fields\n}\n```\nUniversalExecutor is an implementation of the Executor which launches and supervises processes. In addition to process supervision it provides resource and file system isolation\n\n```go\nfunc (e *UniversalExecutor) Exec(deadline time.Time, name string, args []string) ([]byte, int, error)\n```\nExec a command inside a container for exec and java drivers.\n\n```go\nfunc (e *UniversalExecutor) ExecStreaming(ctx context.Context, command []string, tty bool,\n\tstream drivers.ExecTaskStream) error\n```\n\n```go\nfunc (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error)\n```\nLaunch launches the main process and returns its state. It also configures an applies isolation on certain platforms.\n\n```go\nfunc (e *UniversalExecutor) Shutdown(signal string, grace time.Duration) error\n```\nExit cleans up the alloc directory, destroys resource container and kills the user process\n\n```go\nfunc (e *UniversalExecutor) Signal(s os.Signal) error\n```\nSignal sends the passed signal to the task\n\n```go\nfunc (e *UniversalExecutor) Stats(ctx context.Context, interval time.Duration) (\u003c-chan *cstructs.TaskResourceUsage, error)\n```\n\n```go\nfunc (e *UniversalExecutor) UpdateResources(resources *drivers.Resources) error\n```\n\n```go\nfunc (e *UniversalExecutor) Version() (*ExecutorVersion, error)\n```\nVersion returns the api version of the executor\n\n```go\nfunc (e *UniversalExecutor) Wait(ctx context.Context) (*ProcessState, error)\n```\nWait waits until a process has exited and returns it's exitcode and errors\n\n","path":"github.com/bigcommerce/nomad/drivers/shared/executor","name":"executor","synopsis":"","isRedistributable":true}
