panic if no head block after running for 30 seconds
This commit is contained in:
parent
de5674254b
commit
6789050196
|
@ -206,6 +206,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: put sentry behind a feature
|
||||||
let sentry_env = std::env::var("SENTRY_ENV")
|
let sentry_env = std::env::var("SENTRY_ENV")
|
||||||
.map(Cow::from)
|
.map(Cow::from)
|
||||||
.unwrap_or("production".into());
|
.unwrap_or("production".into());
|
||||||
|
|
|
@ -105,6 +105,7 @@ impl ProxydSubCommand {
|
||||||
{
|
{
|
||||||
let mut current_config = config_sender.borrow().clone();
|
let mut current_config = config_sender.borrow().clone();
|
||||||
|
|
||||||
|
// TODO: move this to a helper function
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
match fs::read_to_string(&top_config_path) {
|
match fs::read_to_string(&top_config_path) {
|
||||||
Ok(new_top_config) => {
|
Ok(new_top_config) => {
|
||||||
|
@ -140,7 +141,7 @@ impl ProxydSubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: wait for SIGHUP instead?
|
// TODO: wait for SIGHUP instead?
|
||||||
// TODO: wait for file to change instead of polling?
|
// TODO: wait for file to change instead of polling. file notifications are really fragile depending on the system and setup though
|
||||||
thread::sleep(Duration::from_secs(10));
|
thread::sleep(Duration::from_secs(10));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -157,11 +158,13 @@ impl ProxydSubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("waiting for head block");
|
info!("waiting for head block");
|
||||||
let max_wait_until = Instant::now() + Duration::from_secs(35);
|
let max_wait_until = Instant::now() + Duration::from_secs(30);
|
||||||
loop {
|
loop {
|
||||||
select! {
|
select! {
|
||||||
_ = sleep_until(max_wait_until) => {
|
_ = sleep_until(max_wait_until) => {
|
||||||
return Err(anyhow::anyhow!("oh no! we never got a head block!"))
|
// TODO: an error would be fine if we had automated alerting in sentry
|
||||||
|
// for now, alerts are mostly in pagerduty and pagerduty alerts on panics
|
||||||
|
panic!("oh no! we never got a head block!");
|
||||||
}
|
}
|
||||||
_ = head_block_receiver.changed() => {
|
_ = head_block_receiver.changed() => {
|
||||||
if let Some(head_block) = head_block_receiver
|
if let Some(head_block) = head_block_receiver
|
||||||
|
@ -171,6 +174,7 @@ impl ProxydSubCommand {
|
||||||
info!(head_hash=?head_block.hash(), head_num=%head_block.number());
|
info!(head_hash=?head_block.hash(), head_num=%head_block.number());
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
// this is very unlikely to happen
|
||||||
info!("no head block yet!");
|
info!("no head block yet!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue