Documentation
¶
Overview ¶
Package service provides systemd service management operations. Supports listing, inspecting, and controlling systemd services, and managing custom unit files in /etc/systemd/system/. Delegates unit file writes to the file provider for SHA tracking, idempotency, and template rendering.
Index ¶
- type ActionResult
- type CreateResult
- type Darwin
- func (d *Darwin) Create(_ context.Context, _ Entry) (*CreateResult, error)
- func (d *Darwin) Delete(_ context.Context, _ string) (*DeleteResult, error)
- func (d *Darwin) Disable(_ context.Context, _ string) (*ActionResult, error)
- func (d *Darwin) Enable(_ context.Context, _ string) (*ActionResult, error)
- func (d *Darwin) Get(_ context.Context, _ string) (*Info, error)
- func (d *Darwin) List(_ context.Context) ([]Info, error)
- func (d *Darwin) Restart(_ context.Context, _ string) (*ActionResult, error)
- func (d *Darwin) Start(_ context.Context, _ string) (*ActionResult, error)
- func (d *Darwin) Stop(_ context.Context, _ string) (*ActionResult, error)
- func (d *Darwin) Update(_ context.Context, _ Entry) (*UpdateResult, error)
- type Debian
- func (d *Debian) Create(ctx context.Context, entry Entry) (*CreateResult, error)
- func (d *Debian) Delete(ctx context.Context, name string) (*DeleteResult, error)
- func (d *Debian) Disable(_ context.Context, name string) (*ActionResult, error)
- func (d *Debian) Enable(_ context.Context, name string) (*ActionResult, error)
- func (d *Debian) Get(_ context.Context, name string) (*Info, error)
- func (d *Debian) List(_ context.Context) ([]Info, error)
- func (d *Debian) Restart(_ context.Context, name string) (*ActionResult, error)
- func (d *Debian) Start(_ context.Context, name string) (*ActionResult, error)
- func (d *Debian) Stop(_ context.Context, name string) (*ActionResult, error)
- func (d *Debian) Update(ctx context.Context, entry Entry) (*UpdateResult, error)
- type DeleteResult
- type Entry
- type Info
- type Linux
- func (l *Linux) Create(_ context.Context, _ Entry) (*CreateResult, error)
- func (l *Linux) Delete(_ context.Context, _ string) (*DeleteResult, error)
- func (l *Linux) Disable(_ context.Context, _ string) (*ActionResult, error)
- func (l *Linux) Enable(_ context.Context, _ string) (*ActionResult, error)
- func (l *Linux) Get(_ context.Context, _ string) (*Info, error)
- func (l *Linux) List(_ context.Context) ([]Info, error)
- func (l *Linux) Restart(_ context.Context, _ string) (*ActionResult, error)
- func (l *Linux) Start(_ context.Context, _ string) (*ActionResult, error)
- func (l *Linux) Stop(_ context.Context, _ string) (*ActionResult, error)
- func (l *Linux) Update(_ context.Context, _ Entry) (*UpdateResult, error)
- type Provider
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionResult ¶
ActionResult represents the outcome of a service control action.
type CreateResult ¶
type CreateResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
CreateResult represents the outcome of a unit file creation.
type Darwin ¶
type Darwin struct{}
Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as service management is not available on macOS.
func NewDarwinProvider ¶
func NewDarwinProvider() *Darwin
NewDarwinProvider factory to create a new Darwin instance.
type Debian ¶
type Debian struct {
provider.FactsAware
// contains filtered or unexported fields
}
Debian implements the Provider interface for Debian-family systems. It delegates unit file writes to a FileDeployer for SHA tracking and idempotency. Service control operations use systemctl via exec.Manager.
func NewDebianProvider ¶
func NewDebianProvider( logger *slog.Logger, fs avfs.VFS, fileDeployer file.Deployer, stateKV jetstream.KeyValue, execManager exec.Manager, hostname string, ) *Debian
NewDebianProvider factory to create a new Debian instance.
func (*Debian) Disable ¶
Disable disables a systemd service. If the service is already disabled, it returns Changed: false without taking action.
func (*Debian) Enable ¶
Enable enables a systemd service. If the service is already enabled, it returns Changed: false without taking action.
func (*Debian) List ¶
List returns all systemd services by merging list-units and list-unit-files output.
func (*Debian) Restart ¶
Restart restarts a systemd service. Always returns Changed: true on success.
func (*Debian) Start ¶
Start starts a systemd service. If the service is already active, it returns Changed: false without taking action.
type DeleteResult ¶
type DeleteResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
DeleteResult represents the outcome of a unit file deletion.
type Info ¶
type Info struct {
Name string `json:"name"`
Status string `json:"status"`
Enabled bool `json:"enabled"`
Description string `json:"description,omitempty"`
PID int `json:"pid,omitempty"`
}
Info represents a systemd service.
type Linux ¶
type Linux struct{}
Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported as this is a generic Linux stub.
func NewLinuxProvider ¶
func NewLinuxProvider() *Linux
NewLinuxProvider factory to create a new Linux instance.
type Provider ¶
type Provider interface {
// List returns all systemd services.
List(ctx context.Context) ([]Info, error)
// Get returns a single systemd service by name.
Get(ctx context.Context, name string) (*Info, error)
// Create deploys a new unit file via the file provider.
Create(ctx context.Context, entry Entry) (*CreateResult, error)
// Update redeploys an existing unit file via the file provider.
Update(ctx context.Context, entry Entry) (*UpdateResult, error)
// Delete undeploys a unit file via the file provider.
Delete(ctx context.Context, name string) (*DeleteResult, error)
// Start starts a systemd service.
Start(ctx context.Context, name string) (*ActionResult, error)
// Stop stops a systemd service.
Stop(ctx context.Context, name string) (*ActionResult, error)
// Restart restarts a systemd service.
Restart(ctx context.Context, name string) (*ActionResult, error)
// Enable enables a systemd service.
Enable(ctx context.Context, name string) (*ActionResult, error)
// Disable disables a systemd service.
Disable(ctx context.Context, name string) (*ActionResult, error)
}
Provider implements systemd service management operations.
type UpdateResult ¶
type UpdateResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
UpdateResult represents the outcome of a unit file update.