systemd

package
v0.0.0-...-b918686 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2016 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// the default target for systemd units that we generate
	ServicesTarget = "multi-user.target"

	// the default target for systemd units that we generate
	SocketsTarget = "sockets.target"
)

Variables

View Source
var ErrUnknownRestartCondition = errors.New("invalid restart condition")

ErrUnknownRestartCondition is returned when trying to unmarshal an unknown restart condition

View Source
var JournalctlCmd = jctl

JournalctlCmd is called from Logs to run journalctl; exported for testing.

View Source
var RestartMap = map[string]RestartCondition{
	"never":       RestartNever,
	"on-success":  RestartOnSuccess,
	"on-failure":  RestartOnFailure,
	"on-abnormal": RestartOnAbnormal,
	"on-abort":    RestartOnAbort,
	"always":      RestartAlways,
}
View Source
var SystemctlCmd = run

SystemctlCmd is called from the commands to actually call out to systemctl. It's exported so it can be overridden by testing.

Functions

func EscapeUnitNamePath

func EscapeUnitNamePath(in string) string

EscapeUnitNamePath works like systemd-escape --path FIXME: we could use github.com/coreos/go-systemd/unit/escape.go

and EscapePath from it.

But thats not in the archive and it won't work with go1.3

func IsTimeout

func IsTimeout(err error) bool

IsTimeout checks whether the given error is a Timeout

func MountUnitPath

func MountUnitPath(baseDir, ext string) string

MountUnitPath returns the path of a {,auto}mount unit

Types

type Error

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

Error is returned if the systemd action failed

func (*Error) Error

func (e *Error) Error() string

type Log

type Log map[string]interface{}

A Log is a single entry in the systemd journal

func (Log) Message

func (l Log) Message() string

Message of the Log, if any; otherwise, "-".

func (Log) SID

func (l Log) SID() string

SID is the syslog identifier of the Log, if any; otherwise, "-".

func (Log) String

func (l Log) String() string

func (Log) Timestamp

func (l Log) Timestamp() string

Timestamp of the Log, formatted like RFC3339 to µs precision.

If no timestamp, the string "-(no timestamp!)-" -- and something is wrong with your system. Some other "impossible" error conditions also result in "-(errror message)-" timestamps.

type RestartCondition

type RestartCondition string

RestartCondition encapsulates the different systemd 'restart' options

const (
	RestartNever      RestartCondition = "never"
	RestartOnSuccess  RestartCondition = "on-success"
	RestartOnFailure  RestartCondition = "on-failure"
	RestartOnAbnormal RestartCondition = "on-abnormal"
	RestartOnAbort    RestartCondition = "on-abort"
	RestartAlways     RestartCondition = "always"
)

These are the supported restart conditions

func (RestartCondition) String

func (rc RestartCondition) String() string

func (*RestartCondition) UnmarshalYAML

func (rc *RestartCondition) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML so RestartCondition implements yaml's Unmarshaler interface

type ServiceStatus

type ServiceStatus struct {
	ServiceFileName string `json:"service-file-name"`
	LoadState       string `json:"load-state"`
	ActiveState     string `json:"active-state"`
	SubState        string `json:"sub-state"`
	UnitFileState   string `json:"unit-file-state"`
}

A ServiceStatus holds structured service status information.

type Systemd

type Systemd interface {
	DaemonReload() error
	Enable(service string) error
	Disable(service string) error
	Start(service string) error
	Stop(service string, timeout time.Duration) error
	Kill(service, signal string) error
	Restart(service string, timeout time.Duration) error
	Status(service string) (string, error)
	ServiceStatus(service string) (*ServiceStatus, error)
	Logs(services []string) ([]Log, error)
	WriteMountUnitFile(name, what, where, fstype string) (string, error)
}

Systemd exposes a minimal interface to manage systemd via the systemctl command.

func New

func New(rootDir string, rep reporter) Systemd

New returns a Systemd that uses the given rootDir

type Timeout

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

Timeout is returned if the systemd action failed to reach the expected state in a reasonable amount of time

func (*Timeout) Error

func (e *Timeout) Error() string

Jump to

Keyboard shortcuts

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