{"modulePath":"github.com/zoomfoo/nomad","version":"v0.1.2","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package executor\n\nPackage exec is used to invoke child processes across various platforms to provide the following features:\n\n\\- Least privilege - Resource constraints - Process isolation\n\nA \"platform\" may be defined as coarsely as \"Windows\" or as specifically as \"linux 3.20 with systemd\". This allows Nomad to use best-effort, best- available capabilities of each platform to provide resource constraints, process isolation, and security features, or otherwise take advantage of features that are unique to that platform.\n\nThe \\`semantics of any particular instance are left up to the implementation. However, these should be completely transparent to the calling context. In other words, the Java driver should be able to call exec for any platform and just work.\n\n## Types\n\n```go\ntype Executor interface {\n\t// Limit must be called before Start and restricts the amount of resources\n\t// the process can use. Note that an error may be returned ONLY IF the\n\t// executor implements resource limiting. Otherwise Limit is ignored.\n\tLimit(*structs.Resources) error\n\n\t// ConfigureTaskDir must be called before Start and ensures that the tasks\n\t// directory is properly configured.\n\tConfigureTaskDir(taskName string, alloc *allocdir.AllocDir) error\n\n\t// Start the process. This may wrap the actual process in another command,\n\t// depending on the capabilities in this environment. Errors that arise from\n\t// Limits or Runas may bubble through Start()\n\tStart() error\n\n\t// Open should be called to restore a previous execution. This might be needed if\n\t// nomad is restarted.\n\tOpen(string) error\n\n\t// Wait waits till the user's command is completed.\n\tWait() error\n\n\t// Returns a handle that is executor specific for use in reopening.\n\tID() (string, error)\n\n\t// Shutdown should use a graceful stop mechanism so the application can\n\t// perform checkpointing or cleanup, if such a mechanism is available.\n\t// If such a mechanism is not available, Shutdown() should call ForceStop().\n\tShutdown() error\n\n\t// ForceStop will terminate the process without waiting for cleanup. Every\n\t// implementations must provide this.\n\tForceStop() error\n\n\t// Command provides access the underlying Cmd struct in case the Executor\n\t// interface doesn't expose the functionality you need.\n\tCommand() *cmd\n}\n```\nExecutor is an interface that any platform- or capability-specific exec wrapper must implement. You should not need to implement a Java executor. Rather, you would implement a cgroups executor that the Java driver will use.\n\n```go\nfunc Command(name string, arg ...string) Executor\n```\nCommand is a mirror of exec.Command that returns a platform-specific Executor\n\n```go\nfunc NewExecutor() Executor\n```\n\n```go\nfunc OpenId(id string) (Executor, error)\n```\nOpenId is similar to executor.Command but will attempt to reopen with the passed ID.\n\n```go\ntype LinuxExecutor struct {\n\t// contains filtered or unexported fields\n}\n```\nLinux executor is designed to run on linux kernel 2.8+.\n\n```go\nfunc (e *LinuxExecutor) Command() *cmd\n```\n\n```go\nfunc (e *LinuxExecutor) ConfigureTaskDir(taskName string, alloc *allocdir.AllocDir) error\n```\n\n```go\nfunc (e *LinuxExecutor) ForceStop() error\n```\n\n```go\nfunc (e *LinuxExecutor) ID() (string, error)\n```\nIf cgroups are used, the ID is the cgroup structurue. Otherwise, it is the PID of the spawn-daemon process. An error is returned if the process was never started.\n\n```go\nfunc (e *LinuxExecutor) Limit(resources *structs.Resources) error\n```\n\n```go\nfunc (e *LinuxExecutor) Open(id string) error\n```\nOpen's behavior is to kill all processes associated with the id and return an error. This is done because it is not possible to re-attach to the spawn-daemon's stdout to retrieve status messages.\n\n```go\nfunc (c *LinuxExecutor) SetGID(groupid string) error\n```\nSetGID changes the Gid for this command (must be set before starting)\n\n```go\nfunc (c *LinuxExecutor) SetUID(userid string) error\n```\nSetUID changes the Uid for this command (must be set before starting)\n\n```go\nfunc (e *LinuxExecutor) Shutdown() error\n```\n\n```go\nfunc (e *LinuxExecutor) Start() error\n```\n\n```go\nfunc (e *LinuxExecutor) Wait() error\n```\n\n","path":"github.com/zoomfoo/nomad/client/executor","name":"executor","synopsis":"Package exec is used to invoke child processes across various platforms to provide the following features: - Least privilege - Resource constraints - Process isolation A \"platform\" may be defined as coarsely as \"Windows\" or as specifically as \"linux 3.20 with systemd\".","isRedistributable":true}
