systemd

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTimeOut uint = 60

Variables

This section is empty.

Functions

func CreateChangeInputSchema added in v0.2.0

func CreateChangeInputSchema() *jsonschema.Schema

func CreateListUnitsSchema added in v0.2.0

func CreateListUnitsSchema() *jsonschema.Schema

func GetRestsartReloadParamsSchema

func GetRestsartReloadParamsSchema() (*jsonschema.Schema, error)

func ValidChanges added in v0.2.0

func ValidChanges() []string

func ValidModes added in v0.2.0

func ValidModes() []string

func ValidRestartModes

func ValidRestartModes() []string

return which are define in the upstream documentation as: The mode needs to be one of replace, fail, isolate, ignore-dependencies, ignore-requirements. If "replace" the call will start the unit and its dependencies, possibly replacing already queued jobs that conflict with this. If "fail" the call will start the unit and its dependencies, but will fail if this would change an already queued job. If "isolate" the call will start the unit in question and terminate all units that aren't dependencies of it. If "ignore-dependencies" it will start a unit but ignore all its dependencies. If "ignore-requirements" it will start a unit but only ignore the requirement dependencies. It is not recommended to make use of the latter two options.

func ValidStates

func ValidStates() []string

func ValidUnitFileStates added in v0.2.0

func ValidUnitFileStates() []string

Types

type ChangeUnitStateParams added in v0.2.0

type ChangeUnitStateParams struct {
	Name    string `json:"name" jsonschema:"Exact name of unit to change state"`
	Action  string `json:"action" jsonschema:"Action to perform."`
	Mode    string `json:"mode,omitempty" jsonschema:"Mode when restarting a unit. Defaults to 'replace'."`
	TimeOut uint   `json:"timeout,omitempty" jsonschema:"Time to wait for the operation to finish. Max 60s."`
	Runtime bool   `json:"runtime,omitempty" jsonschema:"Enable/Disable only temporarily (runtime)."`
}

type CheckReloadRestartParams

type CheckReloadRestartParams struct {
	TimeOut uint `` /* 238-byte string literal not displayed */
}

type Connection

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

func NewSystem

func NewSystem(ctx context.Context, auth *auth.AuthKeeper) (conn *Connection, err error)

func NewUser

func NewUser(ctx context.Context) (conn *Connection, err error)

opens a new user connection to the dbus

func (*Connection) ChangeUnitState added in v0.2.0

func (conn *Connection) ChangeUnitState(ctx context.Context, req *mcp.CallToolRequest, params *ChangeUnitStateParams) (res *mcp.CallToolResult, _ any, err error)

func (*Connection) CheckForRestartReloadRunning

func (conn *Connection) CheckForRestartReloadRunning(ctx context.Context, req *mcp.CallToolRequest, params *RestartReloadParams) (res *mcp.CallToolResult, _ any, err error)

check status of reload or restart

func (*Connection) Close

func (conn *Connection) Close()

close the connection

func (*Connection) ListStatesHandler

func (conn *Connection) ListStatesHandler(ctx context.Context) (lst []string, err error)

helper function to get the valid states

func (*Connection) ListUnits added in v0.2.0

func (conn *Connection) ListUnits(ctx context.Context, req *mcp.CallToolRequest, params *ListUnitsParams) (*mcp.CallToolResult, any, error)

type DbusConnection

type DbusConnection interface {
	ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error)
	GetAllPropertiesContext(ctx context.Context, unitName string) (map[string]interface{}, error)
	ReloadOrRestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	RestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	StartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	StopUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	KillUnitContext(ctx context.Context, name string, signal int32)
	EnableUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) (bool, []dbus.EnableUnitFileChange, error)
	DisableUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]dbus.DisableUnitFileChange, error)
	ListUnitFilesContext(ctx context.Context) ([]dbus.UnitFile, error)

	Close()
}

DbusConnection is an interface that abstracts the dbus connection. This is primarily for testing purposes.

type ListUnitsParams added in v0.2.0

type ListUnitsParams struct {
	States     []string `` /* 244-byte string literal not displayed */
	Patterns   []string `json:"patterns,omitempty" jsonschema:"List units by their names or patterns (e.g. '*.service')."`
	Properties bool     `json:"properties,omitempty" jsonschema:"If true, return detailed properties for each unit. Only applies to mode='loaded'."`
	Verbose    bool     `json:"verbose,omitempty" jsonschema:"Return more details in the response."`
	Mode       string   `` /* 135-byte string literal not displayed */
}

type RestartReloadParams

type RestartReloadParams struct {
	Name         string `json:"name" jsonschema:"Exact name of unit to restart"`
	TimeOut      uint   `` /* 238-byte string literal not displayed */
	Mode         string `json:"mode,omitempty" jsonschema:"Mode used for the restart or reload. 'replace' should be used."`
	Forcerestart bool   `` /* 209-byte string literal not displayed */
}

type UnitProperties added in v0.2.0

type UnitProperties struct {
	Id          string `json:"Id"`
	Description string `json:"Description"`

	// Load state info
	LoadState      string `json:"LoadState"`
	FragmentPath   string `json:"FragmentPath"`
	UnitFileState  string `json:"UnitFileState"`
	UnitFilePreset string `json:"UnitFilePreset"`

	// Active state info
	ActiveState          string `json:"ActiveState"`
	SubState             string `json:"SubState"`
	ActiveEnterTimestamp uint64 `json:"ActiveEnterTimestamp"`

	// Process info
	InvocationID   string `json:"InvocationID"`
	MainPID        int    `json:"MainPID"`
	ExecMainPID    int    `json:"ExecMainPID"`
	ExecMainStatus int    `json:"ExecMainStatus"`

	// Resource usage
	TasksCurrent uint64 `json:"TasksCurrent"`
	TasksMax     uint64 `json:"TasksMax"`
	CPUUsageNSec uint64 `json:"CPUUsageNSec"`

	// Control group
	ControlGroup string `json:"ControlGroup"`

	// Exec commands (simplified - would need additional processing)
	ExecStartPre [][]interface{} `json:"ExecStartPre"`
	ExecStart    [][]interface{} `json:"ExecStart"`

	// Additional fields that might be useful
	Restart       string `json:"Restart"`
	MemoryCurrent uint64 `json:"MemoryCurrent"`
}

Jump to

Keyboard shortcuts

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