systemd

package
v0.0.0-...-5f4265e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 17 Imported by: 15

Documentation

Overview

Provides utilities for working with systemd and the journal.

Index

Constants

This section is empty.

Variables

View Source
var ErrLogComplete = errors.New("journal: Closed by caller")
View Source
var ErrLogWriteTimeout = errors.New("journal: Maximum duration exceeded, timeout")
View Source
var ErrNoSuchUnit = db.Error{Name: "org.freedesktop.systemd1.NoSuchUnit"}

Functions

func EnableAndReloadUnit

func EnableAndReloadUnit(systemd Systemd, name string, path ...string) error

func GetUnitFileProperties

func GetUnitFileProperties(path string) (map[string]string, error)

Get the custom properties set in the unit file as a map. TODO: Work with upstream to add an API for this.

func InitializeSystemdFile

func InitializeSystemdFile(fType SystemdFileType, name string, template *template.Template, values interface{}, start bool) error

func IsFileNotFound

func IsFileNotFound(err error) bool

func IsLoadFailed

func IsLoadFailed(err error) bool

func IsNoSuchUnit

func IsNoSuchUnit(err error) bool

func IsUnitLoadState

func IsUnitLoadState(systemd Systemd, unit string, state string) (bool, error)

func IsUnitProperty

func IsUnitProperty(systemd Systemd, unit string, f func(p map[string]interface{}) bool) (bool, error)

func ProcessLogsForUnit

func ProcessLogsForUnit(unit string) (io.ReadCloser, error)

func Require

func Require()

func SafeUnitName

func SafeUnitName(r []byte) string

func SprintSystemdError

func SprintSystemdError(err error) string

func Start

func Start() error

func StartAndEnableUnit

func StartAndEnableUnit(systemd Systemd, name, path, mode string) (string, error)

func StartConnection

func StartConnection() error

func SystemdError

func SystemdError(err error, name string) bool

func WriteLogsTo

func WriteLogsTo(w io.Writer, unit string, previous int, until <-chan time.Time) error

func WriteStatusTo

func WriteStatusTo(w io.Writer, unit string) error

Types

type StubSystemd

type StubSystemd struct {
}

Stub of Systemd interface

func NewStubSystemd

func NewStubSystemd() *StubSystemd

func (*StubSystemd) DisableUnitFiles

func (c *StubSystemd) DisableUnitFiles(files []string, runtime bool) ([]dbus.DisableUnitFileChange, error)

func (*StubSystemd) EnableUnitFiles

func (c *StubSystemd) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []dbus.EnableUnitFileChange, error)

func (*StubSystemd) GetUnitProperties

func (c *StubSystemd) GetUnitProperties(unit string) (map[string]interface{}, error)

func (*StubSystemd) KillUnit

func (c *StubSystemd) KillUnit(name string, signal int32)

func (*StubSystemd) ListUnits

func (c *StubSystemd) ListUnits() ([]dbus.UnitStatus, error)

func (*StubSystemd) LoadUnit

func (c *StubSystemd) LoadUnit(name string) (string, error)

func (*StubSystemd) Reload

func (c *StubSystemd) Reload() error

func (*StubSystemd) ReloadOrRestartUnit

func (c *StubSystemd) ReloadOrRestartUnit(name string, mode string) (string, error)

func (*StubSystemd) ReloadOrTryRestartUnit

func (c *StubSystemd) ReloadOrTryRestartUnit(name string, mode string) (string, error)

func (*StubSystemd) ReloadUnit

func (c *StubSystemd) ReloadUnit(name string, mode string) (string, error)

func (*StubSystemd) RestartUnit

func (c *StubSystemd) RestartUnit(name string, mode string) (string, error)

func (*StubSystemd) RestartUnitJob

func (c *StubSystemd) RestartUnitJob(name string, mode string) error

func (*StubSystemd) SetUnitProperties

func (c *StubSystemd) SetUnitProperties(unit string, runtime bool, properties ...dbus.Property) error

func (*StubSystemd) StartTransientUnit

func (c *StubSystemd) StartTransientUnit(name string, mode string, properties ...dbus.Property) (string, error)

func (*StubSystemd) StartUnit

func (c *StubSystemd) StartUnit(name string, mode string) (string, error)

func (*StubSystemd) StartUnitJob

func (c *StubSystemd) StartUnitJob(name string, mode string) error

func (*StubSystemd) StopUnit

func (c *StubSystemd) StopUnit(name string, mode string) (string, error)

func (*StubSystemd) StopUnitJob

func (c *StubSystemd) StopUnitJob(name string, mode string) error

func (*StubSystemd) Subscribe

func (c *StubSystemd) Subscribe() error

func (*StubSystemd) SubscribeUnits

func (c *StubSystemd) SubscribeUnits(interval time.Duration) (<-chan map[string]*dbus.UnitStatus, <-chan error)

func (*StubSystemd) SubscribeUnitsCustom

func (c *StubSystemd) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*dbus.UnitStatus, *dbus.UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*dbus.UnitStatus, <-chan error)

SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer size of the channels, the comparison function for detecting changes and a filter function for cutting down on the noise that your channel receives.

func (*StubSystemd) TryRestartUnit

func (c *StubSystemd) TryRestartUnit(name string, mode string) (string, error)

func (*StubSystemd) Unsubscribe

func (c *StubSystemd) Unsubscribe() error

type Systemd

type Systemd interface {
	LoadUnit(name string) (string, error)
	StartUnit(name string, mode string) (string, error)
	StartUnitJob(name string, mode string) error
	StopUnit(name string, mode string) (string, error)
	StopUnitJob(name string, mode string) error
	ReloadUnit(name string, mode string) (string, error)
	RestartUnit(name string, mode string) (string, error)
	RestartUnitJob(name string, mode string) error
	TryRestartUnit(name string, mode string) (string, error)
	ReloadOrRestartUnit(name string, mode string) (string, error)
	ReloadOrTryRestartUnit(name string, mode string) (string, error)
	StartTransientUnit(name string, mode string, properties ...dbus.Property) (string, error)
	KillUnit(name string, signal int32)
	GetUnitProperties(unit string) (map[string]interface{}, error)
	SetUnitProperties(name string, runtime bool, properties ...dbus.Property) error
	ListUnits() ([]dbus.UnitStatus, error)
	EnableUnitFiles(files []string, runtime bool, force bool) (bool, []dbus.EnableUnitFileChange, error)
	DisableUnitFiles(files []string, runtime bool) ([]dbus.DisableUnitFileChange, error)

	Subscribe() error
	Unsubscribe() error
	SubscribeUnits(time.Duration) (<-chan map[string]*dbus.UnitStatus, <-chan error)
	SubscribeUnitsCustom(time.Duration, int, func(*dbus.UnitStatus, *dbus.UnitStatus) bool, func(string) bool) (<-chan map[string]*dbus.UnitStatus, <-chan error)

	Reload() error
}

func Connection

func Connection() Systemd

func NewConnection

func NewConnection() (Systemd, error)

type SystemdFileType

type SystemdFileType string
const (
	TargetType SystemdFileType = "target"
	SliceType  SystemdFileType = "slice"
	UnitType   SystemdFileType = "unit"
)

Jump to

Keyboard shortcuts

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