Documentation
¶
Overview ¶
Provides utilities for working with systemd and the journal.
Index ¶
- Variables
- func EnableAndReloadUnit(systemd Systemd, name string, path ...string) error
- func GetUnitFileProperties(path string) (map[string]string, error)
- func InitializeSystemdFile(fType SystemdFileType, name string, template *template.Template, ...) error
- func IsFileNotFound(err error) bool
- func IsLoadFailed(err error) bool
- func IsNoSuchUnit(err error) bool
- func IsUnitLoadState(systemd Systemd, unit string, state string) (bool, error)
- func IsUnitProperty(systemd Systemd, unit string, f func(p map[string]interface{}) bool) (bool, error)
- func ProcessLogsForUnit(unit string) (io.ReadCloser, error)
- func Require()
- func SafeUnitName(r []byte) string
- func SprintSystemdError(err error) string
- func Start() error
- func StartAndEnableUnit(systemd Systemd, name, path, mode string) (string, error)
- func StartConnection() error
- func SystemdError(err error, name string) bool
- func WriteLogsTo(w io.Writer, unit string, previous int, until <-chan time.Time) error
- func WriteStatusTo(w io.Writer, unit string) error
- type StubSystemd
- func (c *StubSystemd) DisableUnitFiles(files []string, runtime bool) ([]dbus.DisableUnitFileChange, error)
- func (c *StubSystemd) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []dbus.EnableUnitFileChange, error)
- func (c *StubSystemd) GetUnitProperties(unit string) (map[string]interface{}, error)
- func (c *StubSystemd) KillUnit(name string, signal int32)
- func (c *StubSystemd) ListUnits() ([]dbus.UnitStatus, error)
- func (c *StubSystemd) LoadUnit(name string) (string, error)
- func (c *StubSystemd) Reload() error
- func (c *StubSystemd) ReloadOrRestartUnit(name string, mode string) (string, error)
- func (c *StubSystemd) ReloadOrTryRestartUnit(name string, mode string) (string, error)
- func (c *StubSystemd) ReloadUnit(name string, mode string) (string, error)
- func (c *StubSystemd) RestartUnit(name string, mode string) (string, error)
- func (c *StubSystemd) RestartUnitJob(name string, mode string) error
- func (c *StubSystemd) SetUnitProperties(unit string, runtime bool, properties ...dbus.Property) error
- func (c *StubSystemd) StartTransientUnit(name string, mode string, properties ...dbus.Property) (string, error)
- func (c *StubSystemd) StartUnit(name string, mode string) (string, error)
- func (c *StubSystemd) StartUnitJob(name string, mode string) error
- func (c *StubSystemd) StopUnit(name string, mode string) (string, error)
- func (c *StubSystemd) StopUnitJob(name string, mode string) error
- func (c *StubSystemd) Subscribe() error
- func (c *StubSystemd) SubscribeUnits(interval time.Duration) (<-chan map[string]*dbus.UnitStatus, <-chan error)
- func (c *StubSystemd) SubscribeUnitsCustom(interval time.Duration, buffer int, ...) (<-chan map[string]*dbus.UnitStatus, <-chan error)
- func (c *StubSystemd) TryRestartUnit(name string, mode string) (string, error)
- func (c *StubSystemd) Unsubscribe() error
- type Systemd
- type SystemdFileType
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 GetUnitFileProperties ¶
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 IsFileNotFound ¶
func IsLoadFailed ¶
func IsNoSuchUnit ¶
func IsUnitLoadState ¶
func IsUnitProperty ¶
func ProcessLogsForUnit ¶
func ProcessLogsForUnit(unit string) (io.ReadCloser, error)
func SafeUnitName ¶
func SprintSystemdError ¶
func StartAndEnableUnit ¶
func StartConnection ¶
func StartConnection() error
func SystemdError ¶
func WriteLogsTo ¶
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) 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 (*StubSystemd) StartTransientUnit ¶
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 ¶
type SystemdFileType ¶
type SystemdFileType string
const ( TargetType SystemdFileType = "target" SliceType SystemdFileType = "slice" UnitType SystemdFileType = "unit" )
Click to show internal directories.
Click to hide internal directories.