supervisor

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KillProcessGroup added in v1.4.0

func KillProcessGroup(cmd *exec.Cmd)

Types

type LogEntry

type LogEntry struct {
	Time   time.Time `json:"time"`
	Line   string    `json:"line"`
	Source string    `json:"source"`
}

LogEntry holds a single log line, its source, and when it was written. Source is "stdout", "stderr", or "invincible".

type ProcessStatus

type ProcessStatus struct {
	Name      string
	State     string
	PID       int
	Cmd       string
	Cwd       string
	Port      int
	PortEnv   string
	Env       map[string]string
	DependsOn []string
	Restarts  int
	StartedAt time.Time
	Watching  bool
}

type Shell added in v1.7.0

type Shell interface {
	Command(cmdStr string) *exec.Cmd
	Join(steps []string) string
}

Shell is the interpreter used to run a process's cmd and build steps. It also knows how to chain multiple build steps into a single command line so that shell state (like a `cd`) persists from one step to the next — each Shell.Command invocation is one interpreter process, so chaining only works within a single invocation, never across separate ones.

type State

type State int
const (
	StateStopped State = iota
	StateStarting
	StateProbing
	StateRunning
	StateCrashed
	StateBuilding
)

func (State) String

func (s State) String() string

type Supervisor

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

func New

func New(cfgs []config.ProcessConfig) *Supervisor

func (*Supervisor) Build added in v1.4.0

func (s *Supervisor) Build(name string, steps []string, cwd string, ctx context.Context) error

Build runs the ordered build steps for the named process, chained into a single shell invocation so that shell state (like a `cd`) carries from one step to the next. Log output is written to the process's invincible log stream. If ctx is cancelled, the build is killed and the state reverts to its previous value.

func (*Supervisor) Log added in v1.4.0

func (s *Supervisor) Log(name, message string)

Log writes a message to a process's invincible log stream.

func (*Supervisor) Logs

func (s *Supervisor) Logs(name string, n int) []LogEntry

func (*Supervisor) Restart

func (s *Supervisor) Restart(name string) error

func (*Supervisor) RestartAll

func (s *Supervisor) RestartAll()

RestartAll restarts every process in dependency order. Each level starts after the previous level has reached running.

func (*Supervisor) SetShell added in v1.7.0

func (s *Supervisor) SetShell(shell string)

SetShell sets the interpreter used to run process and build commands. shell is a project.shell config value: "auto", "cmd", "bash", or "pwsh". Must be called before any process is started.

func (*Supervisor) Start

func (s *Supervisor) Start(name string) error

func (*Supervisor) StartAll

func (s *Supervisor) StartAll()

func (*Supervisor) Status

func (s *Supervisor) Status() []ProcessStatus

func (*Supervisor) Stop

func (s *Supervisor) Stop(name string) error

func (*Supervisor) StopAll

func (s *Supervisor) StopAll()

Jump to

Keyboard shortcuts

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