mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-18 20:32:45 +00:00
Ensure a prompt exit
This commit is contained in:
@@ -129,45 +129,43 @@ impl<T: SlotClock + Clone + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
)
|
||||
};
|
||||
|
||||
info!(
|
||||
log,
|
||||
"Waiting for next slot";
|
||||
"seconds_to_wait" => duration_to_next_slot.as_secs()
|
||||
);
|
||||
|
||||
let (exit_signal, exit_fut) = exit_future::signal();
|
||||
let service = self.clone();
|
||||
let log_1 = log.clone();
|
||||
let log_2 = log.clone();
|
||||
let log_3 = log.clone();
|
||||
|
||||
context.executor.spawn(
|
||||
interval
|
||||
.map_err(move |e| {
|
||||
error! {
|
||||
log_1,
|
||||
"Timer thread failed";
|
||||
"error" => format!("{}", e)
|
||||
}
|
||||
})
|
||||
.and_then(move |_| if exit_fut.is_live() { Ok(()) } else { Err(()) })
|
||||
.for_each(move |_| {
|
||||
if let Err(e) = service.clone().spawn_attestation_tasks() {
|
||||
error!(
|
||||
log_2,
|
||||
"Failed to spawn attestation tasks";
|
||||
"error" => e
|
||||
)
|
||||
} else {
|
||||
trace!(
|
||||
log_2,
|
||||
"Spawned attestation tasks";
|
||||
)
|
||||
}
|
||||
exit_fut
|
||||
.until(
|
||||
interval
|
||||
.map_err(move |e| {
|
||||
error! {
|
||||
log_1,
|
||||
"Timer thread failed";
|
||||
"error" => format!("{}", e)
|
||||
}
|
||||
})
|
||||
.for_each(move |_| {
|
||||
if let Err(e) = service.clone().spawn_attestation_tasks() {
|
||||
error!(
|
||||
log_2,
|
||||
"Failed to spawn attestation tasks";
|
||||
"error" => e
|
||||
)
|
||||
} else {
|
||||
trace!(
|
||||
log_2,
|
||||
"Spawned attestation tasks";
|
||||
)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
// Prevent any errors from escaping and stopping the interval.
|
||||
.then(|_| Ok(())),
|
||||
Ok(())
|
||||
})
|
||||
// Prevent any errors from escaping and stopping the interval.
|
||||
.then(|_| Ok(())),
|
||||
)
|
||||
.map(move |_| info!(log_3, "Shutdown complete")),
|
||||
);
|
||||
|
||||
Ok(exit_signal)
|
||||
|
||||
Reference in New Issue
Block a user