process

package
v0.9.38 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package process provides advisory process discovery, never restart authority.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("safe process discovery/restart requires Linux procfs and pidfd support")
View Source
var ErrWaitStopped = errors.New("stopped waiting; SIGUSR2 was delivered and the process may still restart")

ErrWaitStopped means the signal was delivered, but the caller stopped waiting. It is not a failed or cancelled server-side restart.

Functions

func BuildID

func BuildID(path string) (string, error)

ELF's Go build ID identifies the actual executable, independent of linker version labels. Reading a small note avoids hashing the entire binary at boot.

func HandoffEnviron

func HandoffEnviron() []string

func Instance

func Instance() string

Instance returns the in-memory executable incarnation without registry I/O.

func Report

func Report(phase string, attempt uint64, lastError string)

Report publishes lifecycle state without losing the result of a failed attempt.

func RestoreState

func RestoreState(kind string, value any) (bool, error)

func SaveState

func SaveState(kind string, value any) (func(context.Context), error)

func State

func State(mode, phase, detail string)

State only changes memory and coalesces a notification; it never waits for I/O.

Types

type Publisher

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

Publisher has no filesystem work on the command startup path. One worker owns publication AND final removal: a timed-out Stop cannot race a late writer into resurrecting a record after cleanup. An abruptly exited worker leaves only an advisory stale record, which List validates against the OS.

func Start

func Start(build, executable string) *Publisher

Start publishes this exec instance asynchronously. executable is the captured installed pathname; empty falls back to os.Executable.

func (*Publisher) Stop

func (p *Publisher) Stop()

type Record

type Record struct {
	PID        int    `json:"pid"`
	Start      string `json:"os_start"`
	Instance   string `json:"instance"`
	Build      string `json:"build"`
	BuildID    string `json:"build_id"`
	Executable string `json:"executable"`
	Mode       string `json:"mode"`
	Phase      string `json:"phase"`
	Detail     string `json:"detail,omitempty"`
	Attempt    uint64 `json:"attempt,omitempty"`
	LastError  string `json:"last_error,omitempty"`
}

func List

func List() ([]Record, error)

List never trusts a PID alone. Cleanup is restricted to records whose OS identity is dead/mismatched. Publishers and cleaners hold the same directory lock, so cleanup cannot delete a newly published replacement record.

func Restart

func Restart(ctx context.Context, r Record, wait bool) (Record, error)

Restart opens a pidfd before revalidating the snapshot. No numeric kill fallback: kernels/sandboxes without pidfd fail closed rather than risk PID reuse.

func RestartWithProgress

func RestartWithProgress(ctx context.Context, r Record, wait bool, progress func(string)) (Record, error)

RestartWithProgress reports advisory lifecycle phases while retaining the same identity/build/readiness checks as Restart. The callback runs synchronously and must return promptly. Only the return value confirms replacement success.

Jump to

Keyboard shortcuts

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