Documentation
¶
Overview ¶
Package install writes service-manager unit files (systemd, launchd) for pyry. Used by the `pyry install-service` subcommand.
The package never enables, starts, or otherwise activates the unit — it only writes the file and returns the path. The user runs the platform's own enable/start commands afterward, with the next-step instructions printed by the caller.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFileExists = errors.New("unit file already exists; pass --force to overwrite")
ErrFileExists is returned when the unit file already exists and Force is false.
Functions ¶
func ResolveWorkDir ¶ added in v0.9.1
ResolveWorkDir returns the absolute, canonicalised WorkingDirectory to bake into the unit file, given the user-supplied --workdir flag value (possibly empty), the install-time cwd, and the user's home directory.
If flag is empty, cwd is used. A leading "~" or "~/" is expanded against homeDir. The result is always absolute (via filepath.Abs).
Types ¶
type Options ¶
type Options struct {
// Platform picks the service manager. PlatformAuto detects from GOOS.
Platform Platform
// Name is the instance name. Defaults to "pyry". Used in the unit's
// filename, label, and (when non-default) baked into ExecStart as
// -pyry-name <name> so the supervisor binds to ~/.pyry/<name>.sock.
Name string
// WorkDir is what gets baked into WorkingDirectory. The CLI resolves
// this via [ResolveWorkDir] before calling [Install]; passing an empty
// string is a programming error and will leave the unit's WorkingDirectory
// blank.
WorkDir string
// Binary is the absolute path to the pyry binary. Defaults to
// os.Executable() — the binary currently running.
Binary string
// PathEnv is the PATH environment variable baked into the unit. Defaults
// to the value of $PATH at install time (with $HOME/ rewritten to %h/
// for systemd portability). Users typically don't set this — the
// inherited PATH already covers nvm, pyenv, brew, and other shimmed
// tools their interactive shell sees. Falls back to a conservative
// system PATH if $PATH is unset.
PathEnv string
// ClaudeArgs, if non-empty, are baked into ExecStart after the pyry
// flags. If empty, the unit is written with commented suggestions and
// the user is expected to edit it before starting the service.
ClaudeArgs []string
// Force allows overwriting an existing file. Without it, [Install]
// returns [ErrFileExists] if the destination is already a file.
Force bool
// HomeDir is the user's home directory. Defaults to os.UserHomeDir().
// Exposed for testing.
HomeDir string
// EnvPath is the value of $PATH inherited from the install-time shell.
// Defaults to os.Getenv("PATH"). Exposed for testing.
EnvPath string
}
Options for Install.
type Platform ¶
type Platform int
Platform identifies which service manager the unit is for.
func Install ¶
Install writes the unit file and returns the absolute path it was written to plus the resolved Platform. If the destination already exists and Options.Force is false, returns ErrFileExists without touching it.