Documentation
¶
Overview ¶
Package process provides advisory process discovery, never restart authority.
Index ¶
- Variables
- func BuildID(path string) (string, error)
- func HandoffEnviron() []string
- func Instance() string
- func Report(phase string, attempt uint64, lastError string)
- func RestoreState(kind string, value any) (bool, error)
- func SaveState(kind string, value any) (func(context.Context), error)
- func State(mode, phase, detail string)
- type Publisher
- type Record
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("safe process discovery/restart requires Linux procfs and pidfd support")
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 ¶
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.
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.
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 ¶
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 ¶
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.