Documentation
¶
Index ¶
Constants ¶
const ( OpStop = 'S' // Stop the watchdogd petting. OpContinue = 'C' // Continue the watchdogd petting. OpDisarm = 'D' // Disarm the watchdog. OpArm = 'A' // Arm the watchdog. )
const ( OpResultOk = 'O' // Ok. OpResultError = 'E' // Error. OpResultInvalidOp = 'I' // Invalid Op. )
Variables ¶
Functions ¶
func MonitorOops ¶
func MonitorOops() error
MonitorOops return an error if the kernel logs contain an oops.
func New ¶
func New() (*client, error)
Create a new client to communicate with the watchdog daemon. In the previous implementation, the watchdog was created by finding the process id of the daemon called watchdogd.
func NewClientFromUDS ¶
Types ¶
type Daemon ¶
type Daemon struct {
// CurrentOpts is current operating parameters for the daemon.
//
// It is assigned at the first call of Run and updated on each subsequent call of it.
CurrentOpts *DaemonOpts
// CurrentWd is an open file descriptor to the watchdog device specified in the daemon options.
CurrentWd *watchdog.Watchdog
// PettingOp syncs the signal to continue or stop petting the watchdog.
PettingOp chan int
// PettingOn indicate if there is an active petting session.
PettingOn bool
}
Daemon contains running states of an instance of the daemon.
func NewDaemon ¶ added in v0.15.0
func NewDaemon(opts *DaemonOpts) *Daemon
func (*Daemon) DisarmWatchdog ¶
disarmWatchdog disarm the watchdog if already armed.
func (*Daemon) DoPetting ¶
doPetting sends keepalive signal to Watchdog when necessary.
If at least one of the custom monitors failed check(s), it won't send a keepalive signal.
func (*Daemon) StartPetting ¶
startPetting starts Watchdog petting in a new goroutine.
func (*Daemon) StartServing ¶
func (d *Daemon) StartServing(l *net.UnixListener)
StartServing enters a loop of accepting and processing next incoming watchdogd operation call.
func (*Daemon) StopPetting ¶
stopPetting stops an ongoing petting process if there is.
type DaemonOpts ¶
type DaemonOpts struct {
// Dev is the watchdog device. Ex: /dev/watchdog
Dev string
// nil uses the preset values. 0 disables the timeout.
Timeout time.Duration
PreTimeout time.Duration
// KeepAlive is the length of the keep alive interval.
KeepAlive time.Duration
// Monitors are called before each keepalive interval. If any monitor
// function returns an error, the .
Monitors []func() error
// UDS is the name of daemon's unix domain socket.
UDS string
}
DaemonOpts contain operating parameters for bootstrapping a watchdog daemon.
func (*DaemonOpts) InitFlags ¶ added in v0.15.0
func (d *DaemonOpts) InitFlags() (fs *flag.FlagSet)
Abstract flag initialization to the DaemonOpts struct so we can separately define it for tinygo and non-tinygo builds.