Crates.io | vigil |
lib.rs | vigil |
version | 0.2.1 |
source | src |
created_at | 2018-05-11 00:21:47.756197 |
updated_at | 2023-01-19 19:15:06.920513 |
description | Provides a liveness checking watchdog for detecting deadlocks/livelocks/starvation etc. |
homepage | |
repository | https://github.com/Metaswitch/vigil |
max_upload_size | |
id | 64777 |
size | 15,741 |
Software watchdog library for Rust services.
Install from crates.io by adding vigil
to your Cargo.toml
:
[dependencies]
vigil = "0.1"
Now you can create a Vigil instance which the watched code must notify every so often. If the watched code misses too many notification ticks, the pre-programmed callbacks will be fired to allow you to handle the situation (gather diagnostics, raise an alarm, cancel the stalled task, or even kill the whole process).
let vigil = Vigil::create(10_000,
Some(|| warn!("Watched code missed a watchdog check"),
Some(|| error!("Watched code missed multiple watchdog checks!"),
Some(|| { error!("Deadlock detected, exiting"); std::process::exit(101));
loop {
do_work();
vigil.notify();
}