hostprotect

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package hostprotect writes the OOM protection drop-in for the control plane unit. install.sh writes the same file; a test keeps the two from drifting.

Index

Constants

View Source
const EnvOptOut = "LEVELRAIL_PROTECT"

EnvOptOut set to 0 skips the drop-in, matching install.sh.

View Source
const Marker = "# Written by install.sh (levelrail host protection)."

Marker is the first line of the drop-in. A file without it was edited by hand and is never replaced.

Variables

This section is empty.

Functions

func Render

func Render(service string, getenv func(string) string) (string, error)

Render returns the drop-in text for a service. Values come from the same LEVELRAIL_* variables as install.sh, with the same defaults and checks.

Types

type Host

type Host struct {
	Service    string
	UnitDir    string
	SystemdRun string
	Geteuid    func() int
	Getenv     func(string) string
	Reload     func(context.Context) error
}

Host holds the paths and hooks Apply needs, so tests can point it at a temp tree.

func DefaultHost

func DefaultHost(service string, reload func(context.Context) error) Host

DefaultHost targets the real host for one service name.

func (Host) Apply

func (h Host) Apply(ctx context.Context) (Result, error)

Apply writes the drop-in when running as root under systemd with an installed unit. It never restarts the service; the caller's own restart applies it.

type Result

type Result string

Result says what Apply did.

const (
	Skipped Result = "skipped"
	Current Result = "current"
	Wrote   Result = "wrote"
	Kept    Result = "kept"
)

The outcomes of Apply.

Jump to

Keyboard shortcuts

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