service

package
v0.2.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 13 Imported by: 0

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 only performs install/uninstall/status: 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

View Source
const DefaultServiceName = "vmflow"

DefaultServiceName is the service/unit/registry name used when Config.Name is empty.

Variables

This section is empty.

Functions

func Install

func Install(cfg Config, w io.Writer) error

Install registers, enables, and starts the service.

func Status

func Status(cfg Config, w io.Writer) error

Status prints the current service status to w.

func Uninstall

func Uninstall(cfg Config, w io.Writer) error

Uninstall stops and removes the service. Config and log files are left in place for the operator to clean up.

Types

type Config

type Config struct {
	// 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 Summary

type Summary struct {
	Installed bool
	Running   bool
	Enabled   bool
	State     string
	Detail    string
}

Summary is a compact, cross-platform native service status.

func Inspect

func Inspect(cfg Config) (Summary, error)

Inspect returns native service state without printing the platform service manager's full diagnostic output.

Jump to

Keyboard shortcuts

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