Documentation
¶
Overview ¶
Package apiservice manages the per-user UI API process, never tmux.
Index ¶
Constants ¶
const ActivationRequired = "SIDECAR_API_SOCKET_ACTIVATION"
ActivationRequired marks jobs that must never fall back to binding the browser port themselves. A broken supervisor configuration fails closed.
const Label = "com.haplab.sidecar.api"
const SocketUnit = "sidecar-api.socket"
const Unit = "sidecar-api.service"
Variables ¶
This section is empty.
Functions ¶
func CloseActivated ¶
func CloseActivated(listeners []ActivatedListener)
func ServicePath ¶
ServicePath keeps the PATH entries a background job can trust for as long as it stays installed: absolute, existing directories owned by root or uid that no other user can write to. It drops empty and relative entries (they resolve against the manager's working directory), directories that do not exist yet (another user could create them, as under /tmp), world-writable directories, and directories owned by another user, any of which would let another local user plant a tmux, git or agent binary that the service then runs as the owner. Group-writable directories are kept: on macOS /usr/local/bin is commonly writable by the admin group, whose members can already act as root. Duplicates keep their first position.
func StableExecutable ¶
StableExecutable preserves an argv/PATH link only when it currently names this exact executable. Following that link covers managed and brew upgrades.
Types ¶
type ActivatedListener ¶
ActivatedListener is one descriptor received from the service manager. Empty names (sd_listen_fds) and sidecar-api names are classified by address.
func Activate ¶
func Activate() ([]ActivatedListener, error)
Activate consumes manager descriptors and clears the systemd environment so children cannot mistake them for their own. The manager retains its copies. The systemd protocol is also available on macOS for isolated ExtraFiles proofs.
type Manager ¶
type Manager interface {
Install(context.Context) error
Uninstall(context.Context) error
Status(context.Context) (Status, error)
}
Manager is the service-manager seam. Tests and headless callers inject it.
type Options ¶
type Options struct {
OS string
Home string
ConfigHome string
StateDir string
ConfigPath string
Executable string
Path string
UID int
Run Runner
}
Options pins the user's paths and the stable executable link into the job.
type SocketStatus ¶
type Status ¶
type Status struct {
Socket SocketStatus `json:"socket"`
Manager string `json:"manager"`
Label string `json:"label"`
File string `json:"file"`
Installed bool `json:"installed"`
Loaded bool `json:"loaded"`
Running bool `json:"running"`
PID int `json:"pid"`
Version string `json:"version"`
UIDir *string `json:"ui_dir"`
UIConfigError string `json:"ui_config_error,omitempty"`
LastExit *Exit `json:"last_exit"`
Log string `json:"log"`
Message string `json:"message"`
}