processes

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ProcessRecordPathEnv stores the detached process record path template.
	// The `%PID%` token, if present, is replaced by the running process PID.
	ProcessRecordPathEnv = "KONGCTL_PROCESS_RECORD_FILE"
)

Variables

This section is empty.

Functions

func ReadStartTimeTicks

func ReadStartTimeTicks(pid int) (uint64, error)

ReadStartTimeTicks reads the process start time ticks from /proc/<pid>/stat.

func RedactArgs

func RedactArgs(args []string) []string

RedactArgs returns a copy of args with sensitive flag values redacted.

func RemoveRecordByPID

func RemoveRecordByPID(pid int) error

RemoveRecordByPID removes the process record for pid.

func RemoveRecordByPath

func RemoveRecordByPath(path string) error

RemoveRecordByPath removes a process record file.

func ResolveDir

func ResolveDir() (string, error)

ResolveDir returns the detached process registry directory.

func ResolvePathForPID

func ResolvePathForPID(pid int) (string, error)

ResolvePathForPID returns a concrete record path for a PID.

func ResolvePathFromEnv

func ResolvePathFromEnv(pid int) string

ResolvePathFromEnv resolves the detached process record path from the environment for the provided PID.

func ResolvePathFromTemplate

func ResolvePathFromTemplate(template string, pid int) string

ResolvePathFromTemplate expands a PID token inside a record path template.

func ResolvePathTemplate

func ResolvePathTemplate() (string, error)

ResolvePathTemplate returns the default per-process record path template.

func Terminate

func Terminate(pid int, timeout time.Duration) error

Terminate sends SIGTERM to pid and waits for process exit.

func WaitForStartTimeTicks

func WaitForStartTimeTicks(pid int, timeout time.Duration) uint64

WaitForStartTimeTicks waits for /proc stat start time to become available.

func WriteRecord

func WriteRecord(path string, record Record) error

WriteRecord persists a process record atomically at path.

Types

type Record

type Record struct {
	PID            int       `json:"pid" yaml:"pid"`
	Kind           string    `json:"kind" yaml:"kind"`
	Profile        string    `json:"profile,omitempty" yaml:"profile,omitempty"`
	CreatedAt      time.Time `json:"created_at" yaml:"created_at"`
	LogFile        string    `json:"log_file,omitempty" yaml:"log_file,omitempty"`
	Args           []string  `json:"args,omitempty" yaml:"args,omitempty"`
	StartTimeTicks uint64    `json:"start_time_ticks,omitempty" yaml:"start_time_ticks,omitempty"`
}

Record describes a detached kongctl process.

type RuntimeState

type RuntimeState struct {
	Status                 Status `json:"status" yaml:"status"`
	Running                bool   `json:"running" yaml:"running"`
	ObservedStartTimeTicks uint64 `json:"observed_start_time_ticks,omitempty" yaml:"observed_start_time_ticks,omitempty"`
	CheckError             string `json:"check_error,omitempty" yaml:"check_error,omitempty"`
}

RuntimeState captures live process status for a stored record.

func Inspect

func Inspect(record Record) RuntimeState

Inspect evaluates whether a recorded process is still running.

type Status

type Status string

Status represents the runtime state of a detached process record.

const (
	StatusRunning Status = "running"
	StatusExited  Status = "exited"
	StatusStale   Status = "stale"
	StatusUnknown Status = "unknown"
)

type StoredRecord

type StoredRecord struct {
	Record
	File string `json:"file" yaml:"file"`
}

StoredRecord includes the record and backing file path.

func ListRecords

func ListRecords() ([]StoredRecord, error)

ListRecords returns all stored detached process records.

Jump to

Keyboard shortcuts

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