Documentation
¶
Overview ¶
Package service generates launchd and systemd service unit files for the AgentPaaS daemon (agentpaasd).
It provides:
- Deterministic launchd plist generation for macOS
- Deterministic systemd user unit generation for Linux
- Install/uninstall functions that write or remove the plist file
Generated files contain no timestamps, random values, or non-deterministic content. The same inputs always produce byte-identical output.
The install path is configurable for testing. Install/uninstall only write or remove files — they do NOT load the service (no launchctl/systemctl).
Index ¶
- Constants
- func GenerateLaunchdPlist(cfg LaunchdPlistConfig) ([]byte, error)
- func GenerateSystemdUnit(cfg SystemdUnitConfig) ([]byte, error)
- func InstallLaunchdPlist(cfg LaunchdPlistConfig, launchAgentsDir string, force bool) error
- func LaunchdPlistFilename() string
- func UninstallLaunchdPlist(launchAgentsDir string) error
- type LaunchdPlistConfig
- type SystemdUnitConfig
Constants ¶
const LaunchdLabel = "com.agentpaas.daemon"
LaunchdLabel is the standard launchd job label for agentpaasd.
Variables ¶
This section is empty.
Functions ¶
func GenerateLaunchdPlist ¶
func GenerateLaunchdPlist(cfg LaunchdPlistConfig) ([]byte, error)
GenerateLaunchdPlist generates a macOS launchd plist XML document for agentpaasd.
The output is deterministic: the same config always produces byte-identical XML. No timestamps or random values are included.
func GenerateSystemdUnit ¶
func GenerateSystemdUnit(cfg SystemdUnitConfig) ([]byte, error)
GenerateSystemdUnit generates a systemd user service unit file for agentpaasd.
The output is deterministic: the same config always produces byte-identical output. No timestamps or random values are included.
func InstallLaunchdPlist ¶
func InstallLaunchdPlist(cfg LaunchdPlistConfig, launchAgentsDir string, force bool) error
InstallLaunchdPlist writes the generated launchd plist to the specified launchAgents directory (typically ~/Library/LaunchAgents).
It creates the directory if it does not exist. The file is written with mode 0644. Install does NOT load the service via launchctl — it only writes the plist file.
If force is false and the plist file already exists, an error is returned. Set force to true to overwrite the existing file.
func LaunchdPlistFilename ¶
func LaunchdPlistFilename() string
LaunchdPlistFilename returns the filename for the launchd plist.
func UninstallLaunchdPlist ¶
UninstallLaunchdPlist removes the launchd plist from the specified launchAgents directory.
It is idempotent: if the file does not exist, no error is returned.
Types ¶
type LaunchdPlistConfig ¶
type LaunchdPlistConfig struct {
// Label is the launchd job label. If empty, defaults to defaultLaunchdLabel.
Label string
// DaemonPath is the absolute path to the agentpaasd binary.
DaemonPath string
// HomeDir is the agentpaas home directory, passed via --home.
HomeDir string
// EnvHome, if non-empty, is the AGENTPAAS_HOME environment variable value.
// When set, it is included in the EnvironmentVariables dict in the plist.
EnvHome string
}
LaunchdPlistConfig holds the inputs for generating a launchd plist.
type SystemdUnitConfig ¶
type SystemdUnitConfig struct {
// DaemonPath is the absolute path to the agentpaasd binary.
DaemonPath string
// HomeDir is the agentpaas home directory, passed via --home.
HomeDir string
// EnvHome, if non-empty, is the AGENTPAAS_HOME environment variable value.
// When set, it is included as an Environment= line in the Service section.
EnvHome string
}
SystemdUnitConfig holds the inputs for generating a systemd user service unit.