macosrt

package
v1.5.9 Latest Latest
Warning

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

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

Documentation

Overview

Package macosrt holds the macOS runtime pieces that run on a Mac host: launchd units and doctor checks.

Index

Constants

View Source
const (
	StatusOK      = "ok"
	StatusWarn    = "warn"
	StatusFail    = "fail"
	StatusUnknown = "unknown"
)

Check statuses match the doctor report vocabulary.

View Source
const (

	// DefaultThrottleSeconds is the launchd respawn gap, so a missing identity does not spin.
	DefaultThrottleSeconds = 30
)

Variables

This section is empty.

Functions

func Label

func Label(r Role) string

Label is the launchd job label for a role.

Types

type Deps

type Deps struct {
	GOOS      string
	GOARCH    string
	LookPath  func(string) (string, error)
	Sysctl    func(name string) (string, error)
	Version   func() (string, error)
	FreeBytes func(dir string) (int64, error)
	PortFree  func(port int) bool
	DataDir   string
	// MinFreeGiB and MinMacOSMajor come from env at the call site.
	MinFreeGiB    int
	MinMacOSMajor int
	Ports         []int
}

Deps are the host probes, injected so tests need no real Mac.

type Manager

type Manager struct {
	Dir    string // usually ~/Library/LaunchAgents
	UID    int
	Runner Runner
}

Manager installs units into the per-user LaunchAgents directory.

func (Manager) Install

func (m Manager) Install(ctx context.Context, s Spec) (string, error)

Install writes the plist atomically and (re)loads it. It returns the plist path.

func (Manager) Status

func (m Manager) Status(ctx context.Context, r Role) State

Status reports whether the plist exists and launchd has the job loaded.

func (Manager) Uninstall

func (m Manager) Uninstall(ctx context.Context, r Role) (bool, error)

Uninstall unloads and removes the unit. Missing pieces are not errors.

type Result

type Result struct {
	Code    string
	Name    string
	Status  string
	Message string
	Fix     string
}

Result is one macOS readiness check.

func Run

func Run(d Deps) []Result

Run returns every check. Off macOS it returns a single warn, never a failure.

type Role

type Role string

Role names which Levelrail process a launchd unit runs.

const (
	// RoleControlPlane runs the control plane binary.
	RoleControlPlane Role = "control-plane"
	// RoleAgent runs the node agent.
	RoleAgent Role = "agent"
)

func ParseRole

func ParseRole(s string) (Role, error)

ParseRole accepts the CLI spelling of a role.

type Runner

type Runner interface {
	Run(ctx context.Context, args ...string) ([]byte, error)
}

Runner runs launchctl. Tests pass a fake; production never runs it off macOS.

type Spec

type Spec struct {
	Role            Role
	Binary          string
	Args            []string
	Env             map[string]string
	LogDir          string
	WorkDir         string
	ThrottleSeconds int
}

Spec describes one launchd unit.

func (Spec) Plist

func (s Spec) Plist() ([]byte, error)

Plist renders the unit. Output is deterministic so reinstall is a no-op diff.

func (Spec) Validate

func (s Spec) Validate() error

Validate rejects specs that would write a bad or leaky unit.

type State

type State struct {
	Role      Role   `json:"role"`
	Label     string `json:"label"`
	Path      string `json:"path"`
	Installed bool   `json:"installed"`
	Loaded    bool   `json:"loaded"`
}

State is what Status reports for one role.

Jump to

Keyboard shortcuts

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