projects
/
stakingWatchdog.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
507c694
)
Periodically print a "no error" status
author
Greg Burri
<greg.burri@gmail.com>
Fri, 29 Sep 2023 21:06:09 +0000
(23:06 +0200)
committer
Greg Burri
<greg.burri@gmail.com>
Fri, 29 Sep 2023 21:06:09 +0000
(23:06 +0200)
src/main.rs
patch
|
blob
|
history
diff --git
a/src/main.rs
b/src/main.rs
index
114b915
..
b58f7b3
100644
(file)
--- a/
src/main.rs
+++ b/
src/main.rs
@@
-26,8
+26,9
@@
mod config;
// mod error;
const FILE_CONF: &str = "config.ron";
// mod error;
const FILE_CONF: &str = "config.ron";
-const CHECK_PERIOD: Duration = Duration::from_secs(10); // 10s.
-const EMAIL_RESEND_PERIOD: Duration = Duration::from_secs(6 * 60 * 60); // 6h.
+const CHECK_PERIOD: Duration = Duration::from_secs(10); // 10 s.
+const EMAIL_RESEND_PERIOD: Duration = Duration::from_secs(6 * 60 * 60); // 6 h.
+const STATE_PRINT_PERIOD: Duration = Duration::from_secs(15 * 60); // 15 min.
const BASE_URI: &str = "http://localhost:5052/eth/v1/";
fn main() -> Result<()> {
const BASE_URI: &str = "http://localhost:5052/eth/v1/";
fn main() -> Result<()> {
@@
-44,11
+45,14
@@
fn main() -> Result<()> {
);
let mut time_last_email_send = time::Instant::now() - EMAIL_RESEND_PERIOD;
);
let mut time_last_email_send = time::Instant::now() - EMAIL_RESEND_PERIOD;
+ let mut time_last_state_printed = time::Instant::now() - STATE_PRINT_PERIOD;
+ let mut error_state = false;
loop {
let time_beginning_loop = time::Instant::now();
if let Err(error) = check_validators(&config.pub_keys) {
loop {
let time_beginning_loop = time::Instant::now();
if let Err(error) = check_validators(&config.pub_keys) {
+ error_state = true;
println!("Error: {:?}", error);
if time::Instant::now() - time_last_email_send >= EMAIL_RESEND_PERIOD {
// Send e-mail.
println!("Error: {:?}", error);
if time::Instant::now() - time_last_email_send >= EMAIL_RESEND_PERIOD {
// Send e-mail.
@@
-66,6
+70,16
@@
fn main() -> Result<()> {
}
}
}
}
}
}
+ } else {
+ if error_state {
+ error_state = false;
+ println!("End of erroneous state");
+ }
+
+ if time::Instant::now() - time_last_state_printed >= STATE_PRINT_PERIOD {
+ println!("No error detected");
+ time_last_state_printed = time::Instant::now();
+ }
}
let elapsed = time::Instant::now() - time_beginning_loop;
}
let elapsed = time::Instant::now() - time_beginning_loop;