systemd

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package systemd provides systemd-specific platform implementations.

Index

Constants

View Source
const (
	UnitSuffixContainer = ".container"
	UnitSuffixNetwork   = ".network"
	UnitSuffixVolume    = ".volume"
	UnitSuffixBuild     = ".build"
	UnitSuffixService   = ".service"
)

Unit type suffix constants for Quadlet unit files. These suffixes distinguish different types of managed resources in systemd dependencies.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lifecycle

type Lifecycle struct {
	// contains filtered or unexported fields
}

Lifecycle implements the platform.Lifecycle interface for systemd.

func NewLifecycle

func NewLifecycle(
	unitManager systemd.UnitManager,
	connectionFactory systemd.ConnectionFactory,
	userMode bool,
	logger log.Logger,
) *Lifecycle

NewLifecycle creates a new systemd Lifecycle implementation.

func (*Lifecycle) Exists added in v0.25.0

func (l *Lifecycle) Exists(ctx context.Context, name string) (bool, error)

Exists checks if a service unit exists in systemd.

func (*Lifecycle) Name

func (l *Lifecycle) Name() string

Name returns the platform name.

func (*Lifecycle) Reload

func (l *Lifecycle) Reload(ctx context.Context) error

Reload reloads the service manager configuration.

func (*Lifecycle) Restart

func (l *Lifecycle) Restart(ctx context.Context, name string) error

Restart restarts a service.

func (*Lifecycle) RestartMany

func (l *Lifecycle) RestartMany(ctx context.Context, names []string) map[string]error

RestartMany restarts multiple services in dependency order. Services are processed sequentially to ensure dependencies are restarted before dependents.

func (*Lifecycle) SetUnitGenerationTimeout added in v0.24.7

func (l *Lifecycle) SetUnitGenerationTimeout(timeout time.Duration)

SetUnitGenerationTimeout sets the timeout for waiting for units to be generated. This is primarily useful for testing.

func (*Lifecycle) Start

func (l *Lifecycle) Start(ctx context.Context, name string) error

Start starts a service.

func (*Lifecycle) StartMany

func (l *Lifecycle) StartMany(ctx context.Context, names []string) map[string]error

StartMany starts multiple services in dependency order.

func (*Lifecycle) Status

func (l *Lifecycle) Status(ctx context.Context, name string) (*platform.ServiceStatus, error)

Status returns the status of a service.

func (*Lifecycle) Stop

func (l *Lifecycle) Stop(ctx context.Context, name string) error

Stop stops a service.

func (*Lifecycle) StopMany

func (l *Lifecycle) StopMany(ctx context.Context, names []string) map[string]error

StopMany stops multiple services in reverse dependency order.

type QuadletWriter added in v0.25.0

type QuadletWriter struct {
	// contains filtered or unexported fields
}

QuadletWriter provides a minimal INI writer for Quadlet unit files. It preserves exact formatting, ordering, and behavior of the current renderer. Uses manual formatting instead of go-ini to ensure precise control over output.

func NewQuadletWriter added in v0.25.0

func NewQuadletWriter() *QuadletWriter

NewQuadletWriter creates a new Quadlet INI writer.

func (*QuadletWriter) Append added in v0.25.0

func (w *QuadletWriter) Append(sectionName, key string, values ...string)

Append adds a key multiple times with different values (for multi-value directives). Values are appended in the order provided.

func (*QuadletWriter) AppendKVMap added in v0.25.0

func (w *QuadletWriter) AppendKVMap(sectionName, key string, m map[string]string)

AppendKVMap adds key=k=v pairs from a map in sorted key order (for --env, --label, etc).

func (*QuadletWriter) AppendMap added in v0.25.0

func (w *QuadletWriter) AppendMap(sectionName, key string, m map[string]string, formatter func(k, v string) string)

AppendMap adds key=value pairs from a map in sorted key order.

func (*QuadletWriter) AppendSorted added in v0.25.0

func (w *QuadletWriter) AppendSorted(sectionName, key string, values ...string)

AppendSorted adds multiple values for a key in sorted order.

func (*QuadletWriter) Set added in v0.25.0

func (w *QuadletWriter) Set(sectionName, key, value string)

Set adds a single key=value pair to a section.

func (*QuadletWriter) SetBool added in v0.25.0

func (w *QuadletWriter) SetBool(sectionName, key string, value bool)

SetBool adds a boolean directive as yes/no.

func (*QuadletWriter) String added in v0.25.0

func (w *QuadletWriter) String() string

String renders the INI file to a string with proper Quadlet formatting.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer implements platform.Renderer for systemd/Quadlet.

func NewRenderer

func NewRenderer(logger log.Logger) *Renderer

NewRenderer creates a new systemd renderer.

func (*Renderer) Name

func (r *Renderer) Name() string

Name returns the platform name.

func (*Renderer) Render

func (r *Renderer) Render(_ context.Context, specs []service.Spec) (*platform.RenderResult, error)

Render converts service specs to systemd Quadlet unit files.

Jump to

Keyboard shortcuts

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