systemd

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package systemd implements the tailkitd systemd integration, exposing unit control and journal access over the tailkitd HTTP API.

The D-Bus connection is initialised once at startup and shared across all handlers. Missing systemd.toml → 503 on every endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the go-systemd D-Bus connection with the node's permission config.

func NewClient

func NewClient(ctx context.Context, cfg config.SystemdConfig, logger *zap.Logger) (*Client, error)

NewClient initialises a D-Bus connection to systemd using dbus.NewSystemConnectionContext. A connection failure is logged as a warning but does not prevent tailkitd from starting — Available() will return false and handlers will respond 503 until the connection is restored by a restart.

If cfg.Enabled is false, NewClient returns a non-nil Client whose every handler responds 503 (invariant 5: missing config = 503).

func (*Client) Available

func (c *Client) Available(_ context.Context) bool

Available reports whether the D-Bus connection is live.

func (*Client) Close

func (c *Client) Close()

Close releases the D-Bus connection.

type Handler

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

Handler serves all /integrations/systemd/* endpoints.

func NewHandler

func NewHandler(client *Client, jobs *TailkitdExec.JobStore, logger *zap.Logger) *Handler

NewHandler constructs a systemd Handler.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts all systemd endpoints onto mux.

GET  /integrations/systemd/available
GET  /integrations/systemd/config
GET  /integrations/systemd/units
GET  /integrations/systemd/units/{unit}
GET  /integrations/systemd/units/{unit}/file
POST /integrations/systemd/units/{unit}/start
POST /integrations/systemd/units/{unit}/stop
POST /integrations/systemd/units/{unit}/restart
POST /integrations/systemd/units/{unit}/reload
POST /integrations/systemd/units/{unit}/enable
POST /integrations/systemd/units/{unit}/disable
GET  /integrations/systemd/units/{unit}/journal
GET  /integrations/systemd/journal

type JournalEntry

type JournalEntry struct {
	Timestamp uint64            `json:"timestamp_us"` // realtime timestamp in microseconds
	Message   string            `json:"message"`
	Unit      string            `json:"unit,omitempty"`
	Priority  string            `json:"priority,omitempty"`
	Fields    map[string]string `json:"fields,omitempty"`
}

JournalEntry is the shape returned in journal responses.

Jump to

Keyboard shortcuts

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