systemd

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package systemd provides systemd unit management operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext

func GetContext() context.Context

GetContext returns the systemd operation context.

func GetSystemdConnection

func GetSystemdConnection() (*dbus.Conn, error)

GetSystemdConnection returns a connection to systemd D-Bus.

func GetUnitFailureDetails

func GetUnitFailureDetails(unitName string) string

GetUnitFailureDetails retrieves additional details about a unit failure using dbus.

func ReloadSystemd

func ReloadSystemd() error

ReloadSystemd reloads the systemd configuration.

func RestartChangedUnits

func RestartChangedUnits(changedUnits []UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error

RestartChangedUnits restarts all changed units in dependency-aware order.

func StartUnitDependencyAware

func StartUnitDependencyAware(unitName string, unitType string, dependencyGraph *dependency.ServiceDependencyGraph) error

StartUnitDependencyAware starts or restarts a unit while being dependency-aware.

Types

type BaseUnit

type BaseUnit struct {
	Name string
	Type string
}

BaseUnit provides common implementation for all systemd units.

func NewBaseUnit

func NewBaseUnit(name, unitType string) *BaseUnit

NewBaseUnit creates a new BaseUnit with the given name and type.

func (*BaseUnit) GetServiceName

func (u *BaseUnit) GetServiceName() string

GetServiceName returns the full systemd service name based on unit type.

func (*BaseUnit) GetStatus

func (u *BaseUnit) GetStatus() (string, error)

GetStatus returns the current status of the unit.

func (*BaseUnit) GetUnitName

func (u *BaseUnit) GetUnitName() string

GetUnitName returns the name of the unit.

func (*BaseUnit) GetUnitType

func (u *BaseUnit) GetUnitType() string

GetUnitType returns the type of the unit.

func (*BaseUnit) ResetFailed

func (u *BaseUnit) ResetFailed() error

ResetFailed resets the failed state of the unit.

func (*BaseUnit) Restart

func (u *BaseUnit) Restart() error

Restart restarts the unit.

func (*BaseUnit) Show

func (u *BaseUnit) Show() error

Show displays the unit configuration and status.

func (*BaseUnit) Start

func (u *BaseUnit) Start() error

Start starts the unit.

func (*BaseUnit) Stop

func (u *BaseUnit) Stop() error

Stop stops the unit.

type OrchestrationResult

type OrchestrationResult struct {
	Success bool
	Errors  map[string]error
}

OrchestrationResult represents the result of an orchestration operation.

type Unit

type Unit interface {
	// GetServiceName returns the full systemd service name
	GetServiceName() string

	// GetUnitType returns the type of the unit (container, volume, network, etc.)
	GetUnitType() string

	// GetUnitName returns the name of the unit
	GetUnitName() string

	// GetStatus returns the current status of the unit
	GetStatus() (string, error)

	// Start starts the unit
	Start() error

	// Stop stops the unit
	Stop() error

	// Restart restarts the unit
	Restart() error

	// Show displays the unit configuration and status
	Show() error

	// ResetFailed resets the failed state of the unit
	ResetFailed() error
}

Unit defines the interface for managing systemd units.

type UnitChange

type UnitChange struct {
	Name string
	Type string
	Unit Unit
}

UnitChange represents a unit that has changed and needs to be restarted.

Jump to

Keyboard shortcuts

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