Skip to content

Commit

Permalink
handle bootstrap error
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Oct 18, 2021
1 parent f258062 commit 7ab313e
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions explorer/src/main.rs
Expand Up @@ -229,11 +229,22 @@ async fn main() -> Result<(), Error> {
services.push(interrupt_handler);

let (exit_status, remaining_services) = {
let bootstrap_status = bootstrap.await;
let bootstrap_status = bootstrap
.await
.context("panic during bootstrap task")
.map_err(Error::UnrecoverableError)
.and_then(std::convert::identity);

if bootstrap_status.is_ok() {
let (status, _idx, rest) = future::select_all(services).await;
(status, rest)

(
status
.context("task finished with a panic")
.map_err(Error::UnrecoverableError)
.and_then(std::convert::identity),
rest,
)
} else {
(bootstrap_status, services)
}
Expand All @@ -243,10 +254,6 @@ async fn main() -> Result<(), Error> {

let _ = state_tx.send(GlobalState::ShuttingDown);

let exit_status = exit_status
.map_err(|e| Error::UnrecoverableError(e.into()))
.and_then(std::convert::identity);

if let Err(error) = exit_status.as_ref() {
tracing::error!("process finished with error: {:?}", error);

Expand Down Expand Up @@ -381,7 +388,11 @@ async fn rest_service(mut state: broadcast::Receiver<GlobalState>, settings: Set
}
});

let indexer = indexer_rx.await.unwrap();
let indexer = if let Ok(indexer) = indexer_rx.await {
indexer
} else {
return;
};

let api = api::filter(
indexer.db,
Expand Down

0 comments on commit 7ab313e

Please sign in to comment.