Documentation ¶
Overview ¶
Package procworker implements a worker that reads a subprocess specification task, executes it, and puts results into an outbox.
Basically, it runs what you ask it to run, and pushes results where you want them.
Because of this, YOU SHOULD NEVER USE THIS. Really. Just don't. It's super dangerous - anyone that has access to push tasks into your queue can make you run arbitrary things as your process user. That's horrible and bad and scary, even in a controlled environment.
Containers do not make this better, at least not better enough.
Index ¶
Constants ¶
const MaxStdOutSize = 1024 * 1024
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run is a function that can be passed to a worker's Run method. The worker will call this for each task it wishes to process. It pulls subprocess call information from its input task, including which outbox to write results to. If no outbox is specified, the input task's queue name is suffixed with "/done" to produce one.
Types ¶
type SubprocessInput ¶
type SubprocessInput struct { Cmd []string `json:"cmd"` Dir string `json:"dir"` Env []string `json:"env"` Outbox string `json:"outbox"` Errbox string `json:"errbox"` // Directory names for stdout and stderr. If empty, outputs as string into // Stdout and Stderr fields. If specified, creates a random file // name.stdout/stderr file. Outdir string `json:"outdir"` Errdir string `json:"errdir"` // Err is the most recent error, in case this is moved to a failure queue // before a process can start. Err string `json:"err"` }
SubprocessInput contains information about the subprocess to run. Task values should be JSON-encoded versions of this structure.
func (*SubprocessInput) AsOutput ¶
func (p *SubprocessInput) AsOutput() *SubprocessOutput
AsOutput creates an output structure from the input, for filling in results.
func (*SubprocessInput) JSON ¶
func (p *SubprocessInput) JSON() []byte
JSON creates JSON from the input.
type SubprocessOutput ¶
type SubprocessOutput struct { Cmd []string `json:"cmd"` Dir string `json:"dir"` Env []string `json:"env"` Err string `json:"err"` Outdir string `json:"outdir"` Errdir string `json:"errdir"` Stdout string `json:"stdout"` Stderr string `json:"stderr"` // If Outfile and Errfile were specified in the input, this contains // the final full pathnames of those files. Outfile string `json:"outfile"` Errfile string `json:"errfile"` }
SubprocessOutput contains results from the subprocess that was run. Task values pushed to the outbox will contain this as a JSON-encoded string.
func (*SubprocessOutput) JSON ¶
func (p *SubprocessOutput) JSON() []byte
JSON creates JSON from the input.
type TeeWriter ¶
type TeeWriter struct {
// contains filtered or unexported fields
}
TeeWriter writes to two writers what is written to it.
func NewTeeWriter ¶
NewTeeWriter crates a new TeeWriter with the given writers to fan input out to.