bgservice

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package bgservice registers the CashPilot executable with the current user's OS service manager so its headless --daemon supervisor auto-starts at login, restarts on crash, and survives the GUI being closed and a reboot — Docker-parity native supervision with no admin (see docs/NATIVE-SUPERVISION.md, Phase B).

The OS keeps ONE process alive (our signed binary, run with --daemon); that helper in turn supervises the third-party earners. This package only handles the "keep the helper alive" registration; the supervisor itself lives in internal/runtime.

Each supported OS has its own implementation behind a build tag:

agent_darwin.go   launchd LaunchAgent  (~/Library/LaunchAgents/<label>.plist + launchctl)
agent_linux.go    systemd --user unit  (~/.config/systemd/user/<name>.service + systemctl --user)
agent_windows.go  per-user Scheduled Task (schtasks /create /xml, LogonTrigger)

The file-content generation (plist / unit / task XML) is kept in render.go and the service-manager output parsing in parse.go — both free of any build tag and any shell-out — so they are unit-testable on any CI runner regardless of GOOS.

Index

Constants

View Source
const DefaultLabel = "cloud.cashpilot.desktop.helper"

DefaultLabel is the stable reverse-DNS identifier for the CashPilot login agent. It is the launchd Label on macOS and is reused as the human-facing Status.Label on the other OSes (which key their registration off a service-manager-friendly name derived below).

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// Install registers the binary at execPath to run with args (["--daemon"]) at
	// login, kept alive by the OS. It is idempotent-friendly but explicit: callers
	// invoke it in response to a user action, never automatically on startup.
	Install(execPath string, args []string) error
	// Uninstall removes the registration and its backing file, leaving the system as
	// if Install had never run. Removing an absent agent is not an error.
	Uninstall() error
	// Status reports whether the agent is installed and currently running.
	Status() (Status, error)
}

Agent registers, removes, and reports on the CashPilot login agent for one OS.

func New

func New(label, logDir string) Agent

New returns the Linux login agent. logDir is retained for parity with the other OSes; systemd captures the helper's output via the journal rather than an explicit file.

type Status

type Status struct {
	// Installed is true when the agent is registered with the OS service manager
	// (its plist / unit / scheduled task exists).
	Installed bool `json:"installed"`
	// Running is true when the service manager reports the helper process as currently
	// alive (has a live PID / active state).
	Running bool `json:"running"`
	// Label is the OS-native identifier for the registration (launchd label, systemd
	// unit name, or scheduled-task path) — what you would use to inspect it by hand.
	Label string `json:"label"`
}

Status is a snapshot of the login agent's registration state.

Jump to

Keyboard shortcuts

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