Documentation ¶
Overview ¶
Package systemd provides a Go implementation of systemd related protocols.
Currently, the followwing features are supported:
- sd_notify: It can be used to inform systemd of service start-up completion, watchdog events, and other status changes. See: https://www.freedesktop.org/software/systemd/man/sd_notify.html#Description
Index ¶
- Constants
- Variables
- func Files(unsetEnv bool) []*os.File
- func Listeners() (listeners []net.Listener, err error)
- func ListenersWithNames() (map[string][]net.Listener, error)
- func Notify(unsetEnv bool, messages ...string) (bool, error)
- func NumFiles() int
- func WatchdogEnabled(unsetEnv bool) (interval time.Duration, err error)
Constants ¶
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 ¶
var ErrNegativeWatchdogInterval = errors.New("WATCHDOG_USEC must be a positive number")
Functions ¶
func Files ¶ added in v0.9.0
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 ListenersWithNames ¶ added in v0.9.0
ListenersWithNames maps a listener name to a set of net.Listener instances.
func Notify ¶
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 WatchdogEnabled ¶
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.