procsup

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package procsup runs long-lived local helper processes (voice and language servers), one per key, and stops them with the daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(cmd *exec.Cmd)

Prepare makes cmd die with the daemon: Linux kills it when the daemon's thread that started it exits.

Types

type Process

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

Process is a supervised child process.

func (*Process) PID

func (p *Process) PID() int

func (*Process) RSS

func (p *Process) RSS() uint64

RSS is the resident memory of the process in bytes; 0 when unknown.

func (*Process) Running

func (p *Process) Running() bool

func (*Process) Stdout added in v0.2.1

func (p *Process) Stdout() io.Reader

Stdout is the process's stdout pipe (Spec.Stdout); it ends when the process exits.

func (*Process) Use

func (p *Process) Use(fn func(stdin io.Writer) error) error

Use runs fn with the process's stdin, one caller at a time.

type Spec

type Spec struct {
	Key    string
	Path   string
	Args   []string
	Env    []string // nil inherits the daemon's environment
	Stdin  bool     // keep a stdin pipe
	Stdout bool     // keep a stdout pipe
	Log    string   // stderr log file name in the supervisor's log dir; "" discards
	// Ready is one readiness probe; the supervisor repeats it until it passes,
	// the process exits or ReadyTimeout ends. Nil means started is ready.
	Ready        func(ctx context.Context) error
	ReadyTimeout time.Duration
}

Spec describes a process; two specs with the same command, environment and stdin mode run the same process.

type Supervisor

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

func New

func New(logDir string) *Supervisor

func (*Supervisor) Running

func (s *Supervisor) Running(key string) (*Process, bool)

Running is the live process of key.

func (*Supervisor) Start

func (s *Supervisor) Start(ctx context.Context, spec Spec) (*Process, error)

Start returns the running process of spec.Key when it was started from the same command, else replaces it, and waits until it is ready. The probe runs outside the supervisor lock; concurrent Starts of one key share it.

func (*Supervisor) Stop

func (s *Supervisor) Stop(key string)

func (*Supervisor) StopAll

func (s *Supervisor) StopAll()

StopAll stops every process; the daemon calls it on shutdown.

Jump to

Keyboard shortcuts

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