systemd

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package systemd provides a Go implementation of systemd related protocols.

Currently, the followwing features are supported:

Index

Constants

View Source
const (
	// NotifyReady tells the service manager that service startup is finished
	// or the service finished loading its configuration.
	NotifyReady = "READY=1"

	// NotifyStopping tells the service manager that the service is beginning
	// its shutdown.
	NotifyStopping = "STOPPING=1"

	// NotifyReloading tells the service manager that this service is
	// reloading its configuration. Note that you must call SdNotifyReady when
	// it completed reloading.
	NotifyReloading = "RELOADING=1"

	// NotifyWatchdog tells the service manager to update the watchdog
	// timestamp for the service.
	NotifyWatchdog = "WATCHDOG=1"
)

Variables

View Source
var ErrNegativeWatchdogInterval = errors.New("WATCHDOG_USEC must be a positive number")

Functions

func Files added in v0.9.0

func Files(unsetEnv bool) []*os.File

Files returns a slice containing a `os.File` object for each file descriptor passed to this process via systemd fd-passing protocol.

The order of the file descriptors is preserved in the returned slice. `unsetEnv` is typically set to `true` in order to avoid clashes in fd usage and to avoid leaking environment flags to child processes.

func Listeners added in v0.9.0

func Listeners() (listeners []net.Listener, err error)

Listeners returns a slice of net.Listener instances.

func ListenersWithNames added in v0.9.0

func ListenersWithNames() (map[string][]net.Listener, error)

ListenersWithNames maps a listener name to a set of net.Listener instances.

func Notify

func Notify(unsetEnv bool, messages ...string) (bool, error)

Notify sends a message to the init daemon. It is common to ignore the error. If `unsetEnv` is true, the environment variable `NOTIFY_SOCKET` will be unconditionally unset.

It returns one of the following: (false, nil) - notification not supported (i.e. NOTIFY_SOCKET is unset). (false, err) - notification supported, but failure happened (e.g. error connecting to NOTIFY_SOCKET or while sending data). (true, nil) - notification supported, data has been sent.

func NumFiles added in v0.9.0

func NumFiles() int

func WatchdogEnabled

func WatchdogEnabled(unsetEnv bool) (interval time.Duration, err error)

WatchdogEnabled returns watchdog information for a service. Processes should call daemon.SdNotify(false, daemon.SdNotifyWatchdog) every time / 2. If `unsetEnv` is true, the environment variables `WATCHDOG_USEC` and `WATCHDOG_PID` will be unconditionally unset.

It returns one of the following: (0, nil) - watchdog isn't enabled or we aren't the watched PID. (0, err) - an error happened (e.g. error converting time). (time, nil) - watchdog is enabled and we can send ping. time is delay before inactive service will be killed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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