View Source Nerves.Runtime.Heart (nerves_runtime v0.13.0)
Functions for querying Nerves Heart and the device's watchdog
Nerves Heart integrates Erlang's
heart process with a hardware
watchdog. This makes it possible for a device to recover from a hang. The
way it works is that the Erlang runtime regularly checks that it's ok. If so,
it sends a message to heart
. Nerves heart then pets the hardware watchdog.
If messages ever stop being sent to heart
, the hardware watchdog will trip
and reboot the device. You can add additional health checks for your
application by providing a callback to :heart.set_callback/2
.
Link to this section Summary
Functions
Return whether Nerves heart is running
Raising version of status/0
Return the current Nerves Heart status
Link to this section Types
@type info() :: %{ program_name: String.t(), program_version: Version.t(), identity: String.t(), firmware_version: non_neg_integer(), options: non_neg_integer() | [atom()], time_left: non_neg_integer(), pre_timeout: non_neg_integer(), timeout: non_neg_integer(), last_boot: :power_on | :watchdog, heartbeat_timeout: non_neg_integer() }
Nerves Heart's current status
:program_name
-"nerves_heart"
:program_version
- Nerves heart's version number:identity
- The hardware watchdog that's being used:firmware_version
- An integer that represents the hardware watchdog's firmware revision:options
- Hardware watchdog options as reported by Linux:time_left
- How many seconds are left before the hardware watchdog triggers a reboot:pre_timeout
- How many seconds before the watchdog expires that Linux will receive a pre-timeout notification:timeout
- The hardware watchdog timeout. This is only changeable in the Linux configuration:last_boot
- What caused the most recent boot. Whether this is reliable depends on the watchdog.:heartbeat_timeout
- Erlang's heartbeat timeout setting. Note that the hardware watchdog timeout supersedes this since it reboots.
Link to this section Functions
@spec running?() :: boolean()
Return whether Nerves heart is running
If you're using a Nerves device, this always returns true
except possibly
when porting Nerves to new hardware. It is a quick sanity check.
@spec status!() :: info()
Raising version of status/0
@spec status() :: {:ok, info()} | :error
Return the current Nerves Heart status
Errors are returned when not running Nerves Heart