systemd

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Status(context.Context, Unit) (*Status, error)
	Enable(context.Context, Unit) error
	Disable(context.Context, Unit) error
	Start(context.Context, Unit) error
	Stop(context.Context, Unit) error
	Restart(context.Context, Unit) error
}

func NewSSH

func NewSSH(opts *ClientOptions[SSH]) (Client, error)

type ClientOptions

type ClientOptions[T any] struct {
	Transport T      `yaml:"transport"`
	Units     []Unit `yaml:"units"`
}

func ConfigureSSH

func ConfigureSSH(provider config.Provider) (*ClientOptions[SSH], error)

type Emitter

type Emitter interface {
	event.Emitter[string, Status]
}

func NewEmitter

func NewEmitter(services *ServiceFactory, logger *slog.Logger) (Emitter, error)

type SSH

type SSH struct {
	User    string `yaml:"user"`
	Address string `yaml:"address"`
	KeyPath string `yaml:"key_path"`
}

func (SSH) Key

func (transport SSH) Key() (goph.Auth, error)

Key loads the SSH key for the configured remote user.

type Service

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

func (Service) Disable

func (svc Service) Disable(ctx context.Context) error

func (Service) Enable

func (svc Service) Enable(ctx context.Context) error

func (Service) Restart

func (svc Service) Restart(ctx context.Context) error

func (Service) Start

func (svc Service) Start(ctx context.Context) error

func (Service) Status

func (svc Service) Status(ctx context.Context) (*Status, error)

func (Service) Stop

func (svc Service) Stop(ctx context.Context) error

func (Service) Unit

func (svc Service) Unit() Unit

type ServiceFactory

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

func NewServiceFactory

func NewServiceFactory(opts *ClientOptions[SSH]) *ServiceFactory

func (*ServiceFactory) Create

func (f *ServiceFactory) Create(instance string) (*Service, error)

func (ServiceFactory) Units

func (f ServiceFactory) Units() []Unit

type Status

type Status int
const (
	StatusActiveRunning Status = iota // active (running)
	StatusActiveExited                // active (exited)
	StatusActiveWaiting               // active (waiting)
	StatusInactive                    // inactive
	StatusEnabled                     // enabled
	StatusDisabled                    // disabled
	StatusFailed                      // failed
	StatusStatic                      // static
	StatusMasked                      // masked
	StatusAlias                       // alias
	StatusLinked                      // linked
)

func (Status) String

func (i Status) String() string

func (*Status) UnmarshalText

func (s *Status) UnmarshalText(data []byte) error

type Unit

type Unit struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Instance    string `yaml:"instance"`
}

func (Unit) String

func (u Unit) String() string

Jump to

Keyboard shortcuts

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