systemd

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package systemd provides zero-dependency Linux systemd sd_notify and watchdog integration.

Index

Constants

View Source
const (
	Ready     = "READY=1"
	Stopping  = "STOPPING=1"
	Watchdog  = "WATCHDOG=1"
	Reloading = "RELOADING=1"
)

State constants for sd_notify.

Variables

View Source
var LookPath = exec.LookPath

LookPath finds the package manager; tests replace it.

Functions

func Notify

func Notify(state string) error

Notify sends a state notification to the systemd service manager if running under systemd. If NOTIFY_SOCKET is not set (e.g. on Windows, dev mode, or non-systemd init), it returns nil.

func StartWatchdog

func StartWatchdog(ctx context.Context, logf func(string, ...any)) bool

StartWatchdog starts a background goroutine that periodically pings systemd with WATCHDOG=1 at half the configured WATCHDOG_USEC interval until ctx is cancelled. Returns false if watchdog is not enabled by systemd.

func WatchdogInterval

func WatchdogInterval() time.Duration

WatchdogInterval returns the duration specified in WATCHDOG_USEC, or 0 if disabled.

Types

type Upgrader added in v1.0.0

type Upgrader struct {
	Log *slog.Logger
	// Run runs a command and returns its combined output; tests replace it.
	Run func(ctx context.Context, name string, args ...string) (string, error)
}

Upgrader upgrades the host's packages.

func (*Upgrader) Upgrade added in v1.0.0

func (u *Upgrader) Upgrade(ctx context.Context, reboot bool) (string, error)

Upgrade upgrades every package and, with reboot, restarts the host afterwards. It waits for the upgrade to finish (a reboot ends the connection first) and returns the unit name.

Jump to

Keyboard shortcuts

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