Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
🥅 Do not fail the web app if failed to reload the model
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Jul 8, 2023
1 parent 2125bbf commit d1aab48
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use axum::{
};
use clap::{crate_version, Args};
use futures::future::try_join;
use sentry::integrations::tower::{NewSentryLayer, SentryHttpLayer};
use sentry::integrations::{
anyhow::capture_anyhow,
tower::{NewSentryLayer, SentryHttpLayer},
};
use tower::ServiceBuilder;
use tower_http::trace::TraceLayer;
use tracing::info;
Expand Down Expand Up @@ -135,9 +138,17 @@ impl Web {
info!(?interval, "🚀 Running the model updater…");
loop {
tokio::time::sleep(interval).await;

info!("⏰ Reloading the model…");
let new_model = models.get_latest().await?;
model.store(Arc::new(new_model));
match models.get_latest().await {
Ok(new_model) => {
model.store(Arc::new(new_model));
}
Err(error) => {
error!("❌ Failed to reload the model: {:#}", error);
capture_anyhow(&error);
}
}
}
}
}

0 comments on commit d1aab48

Please sign in to comment.