Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logs ¶
type Logs struct {
Stdin, Stdout, Stderr string
}
Logs is used to define the filepaths the user command's logs should be redirected to. The files do not need to exist.
type Spawner ¶
type Spawner struct { SpawnPid int SpawnPpid int StateFile string UserPid int // User configuration UserCmd *exec.Cmd Logs *Logs Chroot string // contains filtered or unexported fields }
Spawner is used to start a user command in an isolated fashion that is resistent to Nomad agent failure.
func NewSpawner ¶
NewSpawner takes a path to a state file. This state file can be used to create a new Spawner that can be used to wait on the exit status of a process even through Nomad restarts.
func (*Spawner) SetCommand ¶
SetCommand sets the user command to spawn.
func (*Spawner) Spawn ¶
Spawn does a double-fork to start and isolate the user command. It takes a call-back that is invoked with the pid of the intermediary process. If the call back returns an error, the user command is not started and the spawn is cancelled. This can be used to put the process into a cgroup or jail and cancel starting the user process if that was not successful. An error is returned if the call-back returns an error or the user-command couldn't be started.
func (*Spawner) Valid ¶
Valid checks that the state of the Spawner is valid and that a subsequent Wait could be called. This is useful to call when reopening a Spawner throught client restarts. If Valid a nil error is returned.
func (*Spawner) Wait ¶
func (s *Spawner) Wait() *structs.WaitResult
Wait returns the exit code of the user process or an error if the wait failed.