Documentation
¶
Index ¶
- func ReadLogger(reader io.Reader, writer *log.Logger, errorChan chan<- error)
- type Head
- func (r *Head) Autorestart(doit bool)
- func (r *Head) Clone() *Head
- func (r *Head) Errors() uint64
- func (r *Head) Restarts() uint64
- func (r *Head) RestartsPerMinute() uint64
- func (r *Head) Run() string
- func (r *Head) SetChildEnv(env []string)
- func (r *Head) SetMgInterval(interval time.Duration)
- func (r *Head) Stop()
- func (r *Head) String() string
- func (r *Head) Wait()
- func (r *Head) Write(p []byte) (n int, err error)
- type Sbuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Head ¶
type Head struct { // ID is a generated ID based on the sequence ID string // RestartDelay specified the duration to wait between restarts RestartDelay time.Duration // MaxPSS specifies the maximum PSS size a process may have before being killed MaxPSS int64 // DebugOut is a logger for debug information DebugOut *log.Logger // ErrOut is a logger for errors, generally, emitted by a Head ErrOut *log.Logger // StdErr is a logger for StdErr coming from a process StdErr *log.Logger // StdOut is a logger for StdOut coming from a process StdOut *log.Logger // UID is the uid to run as (leave unset for current user) UID uint32 // GID is the gid to run as (leave unset for current group) GID uint32 // Seq is a pointer to an initialized sequencer Seq *sequence.Seq // Values is a map for implementors to store key-value pairs. Never consulted by the Head library. Values sync.Map // Timeout is a duration after which the process running is stopped, subject to Autorestart Timeout time.Duration // StdInNoNL is a boolean to describe if a NewLine should *not* be appended to lines written to StdIn. // This is advisory-only, and respected by hydra but not necessarily others. StdInNoNL bool // StdInShellEscapeInput is a boolean to describe if strings send to StdIn should be shell-escaped. // This is advisory-only, and respected by hydra but not necessarily others. StdInShellEscapeInput bool // contains filtered or unexported fields }
Head is a struct to contain a process a run. You can Run() the same Head multiple times if you need clones.
func BashDashC ¶
BashDashC creates a head that handles the command in its entirety running as a "bash -c command"
func New ¶
New returns a Head struct, ready to Run() the command with the arguments specified. It would be wise to ensure the errorChan reader is ready before calling Run() to prevent goro plaque.
func (*Head) Autorestart ¶
Autorestart sets whether or not we will automatically restart Heads that "complete"
func (*Head) RestartsPerMinute ¶
RestartsPerMinute returns the number of restarts for this Head instance in the last minute
func (*Head) Run ¶
Run executes a subprocess of the command and arguments specified, restarting it if applicable. The returned channel returns the name of the once it is running, or closes it without a value if it will not run.
func (*Head) SetChildEnv ¶
SetChildEnv takes a list of key=value strings to pass to all spawned processes
func (*Head) SetMgInterval ¶
SetMgInterval sets the interval at which the memory usage is checked, for use with MaxPSS. Default 30s.
func (*Head) Stop ¶
func (r *Head) Stop()
Stop signals all of the running processes to die. May generate error output thereafter.