/*
* API Reference: https://ethereum.github.io/beacon-APIs/
+ *
+ * TODO:
+ * - Check that some processes (nethermind, lightouse) do not exceed a percentage
+ * of total memory. For example 40 %.
*/
use std::{
const FILE_CONF: &str = "config.ron";
const CHECK_PERIOD: Duration = Duration::from_secs(10); // 10 s.
const PING_TIMEOUT: Duration = Duration::from_secs(10); // 10 s.
+
const NUMBER_SUCCESSIVE_ERRORS_SEND_EMAIL: i32 = 2; // Send an email after 2 successive errors.
+
+// Send an emergency email after 10 successive errors.
+const NUMBER_SUCCESSIVE_ERRORS_SEND_EMEGENCY_EMAIL: i32 = 10;
+
const EMAIL_RESEND_PERIOD: Duration = Duration::from_secs(2 * 60 * 60); // 2 h.
const STATE_PRINT_PERIOD: Duration = Duration::from_secs(15 * 60); // 15 min.
const BASE_URI: &str = "http://localhost:5052/eth/v1/";
.and(check_alive_error_mutex.lock().unwrap().as_ref())
{
error_count += 1;
- println!("Error (error_count={}): {:?}", error_count, error);
+ println!("Error {:?} (error_count={}): {}", error, error_count, error);
if error_count >= NUMBER_SUCCESSIVE_ERRORS_SEND_EMAIL
&& time::Instant::now() - time_last_email_send >= EMAIL_RESEND_PERIOD
{
time_last_email_send = time::Instant::now();
}
}
+ } else if error_count == NUMBER_SUCCESSIVE_ERRORS_SEND_EMEGENCY_EMAIL {
+ // Send e-mail.
+ println!("Sending EMERGENCY email...");
+ match send_email(
+ "[EMERGENCY] Watchdog: Staking error",
+ &format!(
+ "[EMERGENCY] Error: {}\n\nNumber of error: {}",
+ error, error_count
+ ),
+ &config.smtp_relay_address,
+ &config.smtp_login,
+ &config.smtp_password,
+ ) {
+ Err(email_error) => println!("Error sending email: {:?}", email_error),
+ _ => {
+ println!("Email successfully sent");
+ time_last_email_send = time::Instant::now();
+ }
+ }
}
} else {
if error_count > 0 {