Documentation
¶
Overview ¶
Package service registers vmflow as a native OS service so it starts at boot and restarts on crash:
- Linux: systemd unit (/etc/systemd/system/<name>.service)
- macOS: launchd daemon (/Library/LaunchDaemons/io.cloudapp.<name>.plist)
- Windows: Windows Service (managed via services.msc / SCM APIs)
The package performs install/start/uninstall/status operations: it generates the unit or plist file and invokes the platform's service manager (systemctl / launchctl / Windows SCM). The runtime itself does not need this package to run: Linux and macOS execute vmflow in the foreground and supervise it via signals; on Windows vmflow detects the SCM at startup (see cmd/vmflow/daemon_windows.go) and reports state itself.
Style follows internal/updater: error-return (no logger in the package), progress streamed to an io.Writer, and file writes use a same-directory temp + rename for atomicity.
Index ¶
Constants ¶
const DefaultServiceName = "vmflow"
DefaultServiceName is the service/unit/registry name used when Config.Name is empty.
Variables ¶
var ( // ErrNotInstalled reports that no native service definition exists. ErrNotInstalled = errors.New("native service is not installed") // ErrPrivilegesRequired reports that starting the native service requires // administrator privileges. ErrPrivilegesRequired = errors.New("administrator privileges are required") )
Functions ¶
func Start ¶
Start starts an existing native service without changing its definition or startup policy. Calling Start for an already-running service succeeds.
Types ¶
type Config ¶
type Config struct {
// Translator localizes human-readable progress output. It does not affect
// service names, paths, arguments, templates, or platform state values.
Translator *i18n.Translator
// BinaryPath is the vmflow executable path. Defaults to the current
// executable when empty.
BinaryPath string
// ConfigPath is the -config path the service runs with. Defaults to the
// platform's system config path when empty.
ConfigPath string
// ServiceName is the service/unit/registry name. Defaults to "vmflow".
ServiceName string
// User is the systemd User= the unit runs as (Linux only). Empty = root.
// When set and the account is missing, install creates it as a system user.
User string
// LogFile redirects daemon logs. On Linux/Windows it is passed to the daemon
// via -log-file; on macOS it sets the launchd capture paths. Windows defaults
// to a durable path under ProgramData because the SCM provides no stdout.
LogFile string
// ControlPort overrides the daemon's loopback-only management port. Zero
// keeps the value from the config file.
ControlPort int
// ExtraArgs are individual extra arguments appended to the daemon command
// line for future daemon flags. Existing daemon flags have dedicated Config
// fields and are rejected here to prevent overriding validated paths.
ExtraArgs []string
}
Config describes how to install or query the vmflow service.
type InstallPlan ¶
InstallPlan is the validated, side-effect-free result of preparing a native service installation. Paths are absolute, symlinks are resolved, and both the binary and config have passed the same trust checks used by Install.
func PlanInstall ¶
func PlanInstall(cfg Config) (InstallPlan, error)
PlanInstall validates a service installation without changing service state. Callers can use it before requesting administrator privileges or presenting an installation plan to a user. Install repeats the validation at commit time.
func PlanInstallTarget ¶
func PlanInstallTarget(cfg Config) (InstallPlan, error)
PlanInstallTarget validates the executable and destination path before an elevated first-run helper creates the system config. It does not require the config file to exist; Install repeats validation against the written file.