Documentation
¶
Index ¶
- Constants
- Variables
- func Available() error
- func EscapeUnitNamePath(in string) string
- func FakeJournalctl(f func(svcs []string, n int, follow bool) (io.ReadCloser, error)) func()
- func FakeStopDelays(checkDelay, notifyDelay time.Duration) func()
- func FakeSystemctl(f func(args ...string) ([]byte, error)) func()
- func IsTimeout(err error) bool
- func MountUnitPath(baseDir string) string
- func NewJournalStreamFile(identifier string, priority syslog.Priority, levelPrefix bool) (*os.File, error)
- func SdNotify(notifyState string) error
- func SocketAvailable() bool
- type Error
- type InstanceMode
- type Log
- type Systemd
- type Timeout
- type UnitStatus
Constants ¶
const ( // the default target for systemd units that we generate ServicesTarget = "multi-user.target" // the target prerequisite for systemd units we generate PrerequisiteTarget = "network.target" // the default target for systemd socket units that we generate SocketsTarget = "sockets.target" // the default target for systemd timer units that we generate TimersTarget = "timers.target" )
Variables ¶
var ServicesDir = "/etc/systemd/system"
Functions ¶
func EscapeUnitNamePath ¶
EscapeUnitNamePath works like systemd-escape --path
func FakeJournalctl ¶
func FakeStopDelays ¶
FakeStopDelays is used from tests so that Stop can be less forgiving there.
func FakeSystemctl ¶
FakeSystemctl is called from the commands to actually call out to systemctl. It's exported so it can be overridden by testing.
func MountUnitPath ¶
MountUnitPath returns the path of a {,auto}mount unit
func NewJournalStreamFile ¶
func NewJournalStreamFile(identifier string, priority syslog.Priority, levelPrefix bool) (*os.File, error)
NewJournalStreamFile creates log stream file descriptor to the journal. The semantics is identical to that of sd_journal_stream_fd(3) call.
func SdNotify ¶
SdNotify sends the given state string notification to systemd.
inspired by libsystemd/sd-daemon/sd-daemon.c from the systemd source
func SocketAvailable ¶
func SocketAvailable() bool
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned if the systemd action failed
type InstanceMode ¶
type InstanceMode int
InstanceMode determines which instance of systemd to control.
SystemMode refers to the system instance (i.e. pid 1). UserMode refers to the the instance launched to manage the user's desktop session. GlobalUserMode controls configuration respected by all user instances on the system.
As GlobalUserMode does not refer to a single instance of systemd, some operations are not supported such as starting and stopping daemons.
const ( SystemMode InstanceMode = iota UserMode GlobalUserMode )
type Log ¶
A Log is a single entry in the systemd journal
type Systemd ¶
type Systemd interface { DaemonReload() error Enable(service string) error Disable(service string) error Start(service ...string) error StartNoBlock(service ...string) error Stop(service string, timeout time.Duration) error Kill(service, signal, who string) error Restart(service string, timeout time.Duration) error Status(units ...string) ([]*UnitStatus, error) IsEnabled(service string) (bool, error) IsActive(service string) (bool, error) LogReader(services []string, n int, follow bool) (io.ReadCloser, error) AddMountUnitFile(name, revision, what, where, fstype string) (string, error) RemoveMountUnitFile(baseDir string) error Mask(service string) error Unmask(service string) error }
Systemd exposes a minimal interface to manage systemd via the systemctl command.
func New ¶
func New(rootDir string, mode InstanceMode, rep reporter) Systemd
New returns a Systemd that uses the given rootDir