service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package service generates init-system integration (systemd units, OpenRC scripts) and installs VORTEX as a managed system service (build plan M1.4). All generation uses text/template from the standard library — no external dependencies (Non-Negotiable Rule #10).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateLogrotate

func GenerateLogrotate(cfg LogrotateConfig) string

GenerateLogrotate renders a complete /etc/logrotate.d/vortex file for cfg.

func GenerateOpenRC

func GenerateOpenRC(cfg OpenRCConfig) string

GenerateOpenRC renders a complete OpenRC init script for cfg.

func GenerateSystemd

func GenerateSystemd(cfg SystemdConfig) string

GenerateSystemd renders a complete systemd unit file for cfg.

func Install

func Install(cfg InstallConfig) error

Install installs VORTEX as a managed system service for the detected (or forced) init system. With DryRun, it prints the actions it would take and writes nothing.

func Uninstall

func Uninstall(cfg InstallConfig) error

Uninstall reverses Install for the given (or detected) init system.

Types

type InitSystem

type InitSystem string

InitSystem identifies the host's service manager.

const (
	InitSystemd InitSystem = "systemd"
	InitOpenRC  InitSystem = "openrc"
	InitUnknown InitSystem = "unknown"
	InitWindows InitSystem = "windows"
)

func DetectInitSystem

func DetectInitSystem() InitSystem

DetectInitSystem inspects the running OS and returns its init system.

type InstallConfig

type InstallConfig struct {
	ExecPath   string
	ConfigPath string
	InitSystem InitSystem // if empty, auto-detect
	DryRun     bool       // print actions without executing
	Out        io.Writer  // where messages are written; defaults to os.Stdout
}

InstallConfig configures Install/Uninstall.

type LogrotateConfig

type LogrotateConfig struct {
	LogPath    string // path of the log file to rotate
	MaxSize    string // rotate when the file reaches this size (e.g. "100M")
	Rotate     int    // number of rotated files to keep
	Compress   bool   // gzip rotated files
	DateExt    bool   // append a date extension to rotated files
	PostRotate string // command run after rotation (e.g. reload to reopen logs)
}

LogrotateConfig holds the values rendered into a logrotate(8) config, used on distributions where VORTEX logs to a file (OpenRC) rather than journald.

func DefaultLogrotateConfig

func DefaultLogrotateConfig() LogrotateConfig

DefaultLogrotateConfig returns production defaults for the logrotate config.

type OpenRCConfig

type OpenRCConfig struct {
	ExecPath   string // absolute path to the vortex binary
	ConfigPath string // absolute path to vortex.cue
	User       string // user the service runs as
	PidFile    string // pidfile path
	LogFile    string // combined stdout/stderr log path
}

OpenRCConfig holds the values rendered into an OpenRC init script (for Alpine, Gentoo, and other OpenRC-based distributions).

func DefaultOpenRCConfig

func DefaultOpenRCConfig(execPath, configPath string) OpenRCConfig

DefaultOpenRCConfig returns an OpenRCConfig with production defaults.

type SystemdConfig

type SystemdConfig struct {
	ExecPath    string // absolute path to the vortex binary
	ConfigPath  string // absolute path to vortex.cue
	User        string // system user the service runs as
	Group       string // system group the service runs as
	Description string // unit description
	After       string // ordering dependency (e.g. network-online.target)
}

SystemdConfig holds the values rendered into a systemd unit file.

func DefaultSystemdConfig

func DefaultSystemdConfig(execPath, configPath string) SystemdConfig

DefaultSystemdConfig returns a SystemdConfig with production defaults filled in, given the binary and config paths.

Jump to

Keyboard shortcuts

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