Documentation
¶
Index ¶
- Constants
- func CloseIfCloseable(c interface{}) error
- func NewTerminatedEarlyError(err error) error
- func RemoveFromSlice[T comparable](l []T, item T) []T
- type CaptureFile
- type CaptureFiles
- type CaptureStreams
- type CloseFunc
- type CloseFuncPointers
- type CloseFuncPtr
- type ConcurrentBufioWriter
- type DynamicMultiWriter
- func (t *DynamicMultiWriter) Append(writers ...io.Writer)
- func (t *DynamicMultiWriter) Remove(writer io.Writer) bool
- func (t *DynamicMultiWriter) RequestAppend(writer io.Writer, timeout time.Duration) bool
- func (t *DynamicMultiWriter) Reset()
- func (t *DynamicMultiWriter) Size() int
- func (t *DynamicMultiWriter) Write(p []byte) (n int, err error)
- func (t *DynamicMultiWriter) WriteString(s string) (n int, err error)
- type OutputType
- type ProcessNotStartedError
- type ProcessStuckError
- type StdReader
- func (r *StdReader) AlwaysKeepFiles(val bool) *StdReader
- func (r *StdReader) AttachStream(outputType OutputType, writer io.Writer, timeout time.Duration) bool
- func (r *StdReader) DetachStream(writer io.Writer) bool
- func (r *StdReader) GracefulTermination(cmd *exec.Cmd) error
- func (r *StdReader) Run() error
- func (r *StdReader) SetFileWriteBufferSize(size int) *StdReader
- func (r *StdReader) SetGracePeriod(period time.Duration) *StdReader
- func (r *StdReader) SetTerminateMainOnly() *StdReader
- func (r *StdReader) SetTerminationSignal(sig syscall.Signal) *StdReader
- func (r *StdReader) Start()
- func (r *StdReader) Wait() chan error
- func (r *StdReader) WithFiles(files CaptureFiles) error
- func (r *StdReader) WithStreams(streams CaptureStreams) *StdReader
- type TerminatedEarlyError
Constants ¶
const ( // GracePeriodTimeDefault specifies the grace period, defaults to 10 seconds GracePeriodTimeDefault = 10 * time.Second // FileWriteBufferDefaultSize default write buffer size for files: 64 KiB FileWriteBufferDefaultSize = 65536 )
Variables ¶
This section is empty.
Functions ¶
func CloseIfCloseable ¶
func CloseIfCloseable(c interface{}) error
func NewTerminatedEarlyError ¶
func RemoveFromSlice ¶
func RemoveFromSlice[T comparable](l []T, item T) []T
Types ¶
type CaptureFile ¶
type CaptureFile struct {
// contains filtered or unexported fields
}
func NewCaptureFile ¶
func NewCaptureFile(path string) *CaptureFile
func (*CaptureFile) WithFlags ¶
func (f *CaptureFile) WithFlags(flags int) *CaptureFile
func (*CaptureFile) WithPermissions ¶
func (f *CaptureFile) WithPermissions(file fs.FileMode, dir fs.FileMode) *CaptureFile
type CaptureFiles ¶
type CaptureFiles struct {
StdOUT *CaptureFile
StdERR *CaptureFile
}
type CloseFuncPointers ¶
type CloseFuncPointers []CloseFuncPtr
type CloseFuncPtr ¶
type CloseFuncPtr *CloseFunc
type ConcurrentBufioWriter ¶
func (*ConcurrentBufioWriter) Flush ¶
func (w *ConcurrentBufioWriter) Flush()
func (*ConcurrentBufioWriter) WriteString ¶
func (w *ConcurrentBufioWriter) WriteString(s string) (int, error)
type DynamicMultiWriter ¶
type DynamicMultiWriter struct {
// contains filtered or unexported fields
}
func NewDynamicMultiWriter ¶
func NewDynamicMultiWriter(writers ...io.Writer) *DynamicMultiWriter
NewDynamicMultiWriter Creates a dynamic multiwriter, that is able to append and remove elements on the fly Implementation is close/identical to io.MultiWriter
func (*DynamicMultiWriter) Append ¶
func (t *DynamicMultiWriter) Append(writers ...io.Writer)
func (*DynamicMultiWriter) Remove ¶
func (t *DynamicMultiWriter) Remove(writer io.Writer) bool
Remove Taken and modified from the original multi.go source for io.MultiReader
func (*DynamicMultiWriter) RequestAppend ¶
RequestAppend This code tries to append a Writer to the running code, it will return false if the request timed out
func (*DynamicMultiWriter) Reset ¶
func (t *DynamicMultiWriter) Reset()
func (*DynamicMultiWriter) Size ¶
func (t *DynamicMultiWriter) Size() int
func (*DynamicMultiWriter) WriteString ¶
func (t *DynamicMultiWriter) WriteString(s string) (n int, err error)
type ProcessNotStartedError ¶
type ProcessNotStartedError struct {
// contains filtered or unexported fields
}
func (*ProcessNotStartedError) Error ¶
func (e *ProcessNotStartedError) Error() string
func (*ProcessNotStartedError) Is ¶
func (e *ProcessNotStartedError) Is(err error) bool
type ProcessStuckError ¶
type ProcessStuckError struct {
PID int
}
func (*ProcessStuckError) Error ¶
func (e *ProcessStuckError) Error() string
func (*ProcessStuckError) Is ¶
func (e *ProcessStuckError) Is(err error) bool
type StdReader ¶
type StdReader struct {
// contains filtered or unexported fields
}
func NewSTDReader ¶
NewSTDReader creates a new capture settings struct You can specify both files and streams or only one.
func (*StdReader) AlwaysKeepFiles ¶
AlwaysKeepFiles if set to true files will be always kept, even if the process terminates early or without output
func (*StdReader) AttachStream ¶
func (r *StdReader) AttachStream(outputType OutputType, writer io.Writer, timeout time.Duration) bool
AttachStream Attach an arbitary writer to the given outputType, if you want to remove it use DetachStream(writer) to do so. Make sure to perform all closing operations yourself! Warning: Attaching a stream dynamically might fail in the case of a blocking Write taking longer than expected!
func (*StdReader) DetachStream ¶
DetachStream detaches an active writer
func (*StdReader) GracefulTermination ¶
GracefulTermination gracefully terminates a process by sending SIGTERM first and then killing it Nothing in here needs a mutex, because we prevent changes once invoked is set to true
func (*StdReader) SetFileWriteBufferSize ¶
SetFileWriteBufferSize sets the write buffer size for the files specified
func (*StdReader) SetGracePeriod ¶
SetGracePeriod sets the amount of time that has to pass before the process is killed if it did not respond to the termination signal.
func (*StdReader) SetTerminateMainOnly ¶
SetTerminateMainOnly Only request the main pid of the process to terminate This is dangerous and might leave processes behind, only use when you know what you are doing
func (*StdReader) SetTerminationSignal ¶
SetTerminationSignal use a custom graceful termination signal, some processes might need it to exit cleanly
func (*StdReader) WithFiles ¶
func (r *StdReader) WithFiles(files CaptureFiles) error
WithFiles Add output files
func (*StdReader) WithStreams ¶
func (r *StdReader) WithStreams(streams CaptureStreams) *StdReader
WithStreams Add streams that are always part of the systemthat are automatically closed by us
type TerminatedEarlyError ¶
type TerminatedEarlyError struct {
// contains filtered or unexported fields
}
func (*TerminatedEarlyError) Error ¶
func (e *TerminatedEarlyError) Error() string
func (*TerminatedEarlyError) Is ¶
func (e *TerminatedEarlyError) Is(err error) bool