systemd

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupFunc

type CleanupFunc func()

type Conn

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

Conn represents a systemd dbus connection

func Connect

func Connect() (*Conn, error)

Connect establishes a dbus SystemBus connection

func (*Conn) DisableUnit

func (c *Conn) DisableUnit(ctx context.Context, unitName string) error

DisableUnit disables a systemd unit

func (*Conn) EnableUnit

func (c *Conn) EnableUnit(ctx context.Context, unitName string) error

EnableUnit enables a systemd unit

func (*Conn) ListUnits

func (c *Conn) ListUnits(ctx context.Context) ([]Unit, error)

func (*Conn) ReloadUnit

func (c *Conn) ReloadUnit(ctx context.Context, unitName string) error

ReloadUnit reloads a systemd unit

func (*Conn) RestartUnit

func (c *Conn) RestartUnit(ctx context.Context, unitName string) error

RestartUnit restarts a systemd unit

func (*Conn) StartUnit

func (c *Conn) StartUnit(ctx context.Context, unitName string) error

StartUnit starts a sytemd unit

func (*Conn) StopUnit

func (c *Conn) StopUnit(ctx context.Context, unitName string) error

StopUnit stops a systemd unit

type Service

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

Service represents a single running systemd unit. The unit is kept alive until Stop is called.

func NewService

func NewService(parentContext context.Context, conf *ServiceConfig) (*Service, error)

NewService creates a new Service

func (*Service) Restart

func (s *Service) Restart(newConfig []byte)

Restart service with new config

func (*Service) Run

func (s *Service) Run(ctx context.Context)

run starts the services maintenance loop

func (*Service) Stop

func (s *Service) Stop()

Stop stops the service.

func (*Service) Stopped

func (s *Service) Stopped() bool

Stopped reports whether the service has stopped.

func (*Service) Stopping

func (s *Service) Stopping() bool

func (*Service) Wait

func (s *Service) Wait()

Wait waits for all of the services goroutines to finish. Must be called after Stop.

type ServiceConfig

type ServiceConfig struct {
	Config     []byte
	ConfigPath string
	UnitName   string
	Cleanup    CleanupFunc
}

ServiceConfig represents config for a systemd service

type Unit

type Unit struct {
	Name        string
	Description string
	LoadState   string
	ActiveState string
}

ListUnits returns a list of systemd units

Jump to

Keyboard shortcuts

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