proc

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package proc manages the supervised glass child process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition func() (ok bool, reason string)

Condition reports whether the supervised process should be started. If it returns false, reason is written to the output buffer.

type Info

type Info struct {
	PID      int
	Restarts int32
	Started  time.Time
}

Info holds a snapshot of supervisor state.

type Option

type Option func(*Supervisor)

Option configures a Supervisor.

func WithCondition

func WithCondition(cond Condition) Option

WithCondition sets a condition that must pass before the process is started. The supervisor checks the condition before each start attempt, backing off exponentially (up to condMaxBackoff) between failed checks.

type Supervisor

type Supervisor struct {
	// contains filtered or unexported fields
}

Supervisor starts and supervises a process, capturing its output.

func New

func New(exe *exec.Executable, opts ...Option) *Supervisor

New returns a new Supervisor.

func (*Supervisor) Follow

func (s *Supervisor) Follow(ctx context.Context) <-chan string

Follow returns a channel that receives new log lines until ctx is cancelled.

func (*Supervisor) Info

func (s *Supervisor) Info() Info

Info returns a snapshot of current supervisor state.

func (*Supervisor) Lines

func (s *Supervisor) Lines() []string

Lines returns the current ring buffer contents in chronological order.

func (*Supervisor) Restart

func (s *Supervisor) Restart()

Restart sends SIGTERM to the running process. The supervision loop restarts it.

func (*Supervisor) Start

func (s *Supervisor) Start(ctx context.Context) error

Start begins the supervision loop in a background goroutine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL