systemd

package
v0.0.1-dev.137 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package systemd renders the canonical runed.service systemd unit.

The unit template lives here, in Go, so it's versioned with the runed binary it describes. Both `runed print-systemd` (operator-facing, used by upgrade-server.sh --refresh-unit) and the installer scripts consume the same source — there is no second template that can drift out of sync with the binary's expectations.

Adding a new directive to the unit (e.g. MemoryHigh, OOMScoreAdjust, a new AmbientCapabilities entry) means editing only the constant in this file. Every upgrade path that uses `runed print-systemd` then picks it up automatically.

The package is named after the init system, not "unit", because future ports to launchd / OpenRC / Windows Service Manager will add sibling packages (pkg/launchd, pkg/openrc, ...) with the same shape. Keeping the namespace explicit avoids overloading a generic "unit" name with systemd-specific semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, opts UnitOptions) (int64, error)

Render writes the unit text to w using opts. Returns the byte count written and any I/O error.

func RenderString

func RenderString(opts UnitOptions) (string, error)

RenderString is a convenience for callers that want the rendered unit as a string (tests, the `runed print-unit` subcommand). The returned string is empty if opts validation fails — callers that care should check the error.

Types

type UnitOptions

type UnitOptions struct {
	// User is the unprivileged Linux user runed runs as.
	User string

	// Group is runed's primary group. Usually matches User.
	Group string

	// BinaryPath is the absolute path to the runed binary on the host.
	BinaryPath string

	// ConfigPath is the runefile path passed to runed via --config.
	// Empty omits the --config flag, letting runed auto-discover.
	ConfigPath string
}

UnitOptions are the inputs the canonical unit template substitutes. Zero values are not valid — use DefaultUnitOptions() to get sensible defaults and override the fields you care about.

func DefaultUnitOptions

func DefaultUnitOptions() UnitOptions

DefaultUnitOptions returns the settings install-server.sh has used historically: rune:rune as the service user, /usr/local/bin/runed as the binary, /etc/rune/runefile.toml as the config.

func (UnitOptions) Validate

func (o UnitOptions) Validate() error

Validate returns an error if required fields are empty. Called from Render before any template substitution so a clear message points at the missing field rather than a half-rendered unit.

Jump to

Keyboard shortcuts

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