Documentation
¶
Overview ¶
Package service installs, loads and checks the stage 2 service units of one Codex home: launchd agents on macOS, systemd user units on Linux. Each home gets an edge (socket-activated: the service manager holds the provider port, plan decision M8) and a brain. Unit names carry the home id, so homes never share a unit. launchctl and systemctl run through an injected Runner.
Index ¶
- Constants
- func Exec(ctx context.Context, name string, args ...string) (string, error)
- type Ensured
- type Manager
- func (m *Manager) Ensure(ctx context.Context, homeID string) (Ensured, error)
- func (m *Manager) Install(ctx context.Context, s Spec) error
- func (m *Manager) Installed(homeID string) []Unit
- func (m *Manager) Status(ctx context.Context, homeID string) []Unit
- func (m *Manager) StatusReadOnly(ctx context.Context, homeID string) ([]Unit, error)
- func (m *Manager) Uninstall(ctx context.Context, homeID string) ([]Unit, error)
- func (m *Manager) Units(homeID string) []Unit
- type Options
- type Runner
- type Spec
- type State
- type Unit
Constants ¶
const ( RoleEdge = "edge" RoleBrain = "brain" )
Roles of a home's units.
const EdgeSocket = "edge"
EdgeSocket names the edge's socket in the launchd Sockets dict and the systemd FileDescriptorName; the edge asks listen.Activated for it.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager installs and checks the units of homes.
func (*Manager) Ensure ¶
Ensure starts a set-up home's units that are down. It does not wait for them to run.
func (*Manager) Install ¶
Install writes the units of s's home and loads them. Units already installed are unloaded first, so a changed port or binary takes effect.
func (*Manager) Status ¶
Status reports the watched units of a home: the edge's socket and the brain.
func (*Manager) StatusReadOnly ¶ added in v0.7.2
StatusReadOnly reports watched unit states and returns errors from the platform status command. It never starts or changes a unit.
type Options ¶
type Options struct {
GOOS string // "darwin" (launchd) or "linux" (systemd)
// Home is the user's home dir; launchd agents go to Library/LaunchAgents.
Home string
// ConfigHome is $XDG_CONFIG_HOME; systemd user units go to
// systemd/user in it. Empty or relative means Home/.config.
ConfigHome string
UID int // launchd's gui/<uid> domain
Run Runner
}
Options select and place a Manager's backend.
type Spec ¶
type Spec struct {
HomeID string
HomePath string
// StateDir is the state base the units pass as --state-dir (plan M3):
// service managers do not see the shell's XDG_STATE_HOME.
StateDir string
// Config is the codex-router config file passed as --config, for the
// same reason; empty passes none.
Config string
Bin string
Port int
// LogDir holds launchd's edge.log and brain.log; systemd uses the
// journal.
LogDir string
}
Spec is what the units of one home run.