Documentation ¶
Overview ¶
Package subproc provides helper utilities for executing the Nomad binary as a child process of the Nomad agent.
The main entrypoint is the Do function, in which the given MainFunc will be executed as a sub-process if the first argument matches the subcommand.
Context can be used to create a context.Context object with a given timeout, and is expected to be used in conjunction with SetExpiration which uses the context's termination to forcefully terminate the child process if it has not exited by itself.
Index ¶
Constants ¶
const ( // ExitSuccess indicates the subprocess completed successfully. ExitSuccess = iota // ExitFailure indicates the subprocess terminated unsuccessfully. ExitFailure // ExitTimeout indicates the subprocess timed out before completion. ExitTimeout )
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do f if nomad was launched as, "nomad [name]". This process will exit without running any other part of Nomad.
func Log ¶
Log the given output to the logger.
r should be a buffer containing output (typically combined stdin + stdout) f should be an HCLogger Print method (e.g. log.Debug)
func SetExpiration ¶
SetExpiration is used to ensure the process terminates, once ctx is complete. A short grace period is added to allow any cleanup to happen first.