systemd

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnitActiveStateActive   = "active"
	UnitActiveStateInactive = "inactive"
	UnitActiveStateFailed   = "failed"
)

Variables

View Source
var ErrUnitNotFound = errors.New("unit not found")

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// DaemonReload triggers a systemd daemon reload to recognize new or changed unit files.
	DaemonReload(ctx context.Context) error

	// EnableUnit enables a systemd unit by name, allowing it to start on boot.
	EnableUnit(ctx context.Context, unitName string) error
	// StartUnit starts a systemd unit by name.
	StartUnit(ctx context.Context, unitName string) error
	// ReloadOrRestartUnit reloads or restarts a systemd unit by name.
	ReloadOrRestartUnit(ctx context.Context, unitName string) error

	// GetUnitStatus retrieves the status of a systemd unit by name.
	// Returns ErrUnitNotFound if no unit with the specified name exists.
	GetUnitStatus(ctx context.Context, unitName string) (dbus.UnitStatus, error)

	// WriteUnitFile writes a systemd unit file with the given name and content.
	WriteUnitFile(ctx context.Context, unitName string, content []byte) error
	// WriteDropInFile writes a systemd drop-in file for the specified unit.
	WriteDropInFile(ctx context.Context, unitName string, dropInName string, content []byte) error
}

Manager defines the interface for interacting with systemd.

func New

func New() Manager

New creates a new instance of the systemd Manager.

Jump to

Keyboard shortcuts

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