From d1aab4859f454033224638e88e3e86d86e8976cb Mon Sep 17 00:00:00 2001 From: Pavel Perestoronin Date: Sat, 8 Jul 2023 18:13:30 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Do=20not=20fail=20the=20web=20ap?= =?UTF-8?q?p=20if=20failed=20to=20reload=20the=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/web.rs b/src/web.rs index c7bea73..fb1873a 100644 --- a/src/web.rs +++ b/src/web.rs @@ -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; @@ -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); + } + } } } }