Content-Length: 264816 | pFad | https://github.com/sebadob/rauthy/commit/be197355437d0338041cc3206421ec638ca938d7

1B Merge pull request #171 from sebadob/app-version-update-notifcation-i… · sebadob/rauthy@be19735 · GitHub
Skip to content

Commit

Permalink
Merge pull request #171 from sebadob/app-version-update-notifcation-i…
Browse files Browse the repository at this point in the history
…mprovement

only send out a notification about a new app version once after a restart
  • Loading branch information
sebadob authored Nov 14, 2023
2 parents 55433f4 + 55bde88 commit be19735
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions rauthy-main/src/schedulers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rauthy_models::events::event::Event;
use rauthy_models::migration::backup_db;
use rauthy_service::auth;
use redhac::{cache_del, QuorumHealthState, QuorumState};
use semver::Version;
use std::collections::HashSet;
use std::env;
use std::ops::{Add, Sub};
Expand Down Expand Up @@ -512,21 +513,24 @@ pub async fn app_version_check(
return;
}

let mut last_version_notification = None;

// do a first check shortly after startup to not wait hours on a fresh install
// tokio::time::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(120)).await;
check_app_version(&data, &rx_health).await;
check_app_version(&data, &rx_health, &mut last_version_notification).await;

let mut interval = time::interval(Duration::from_secs(3595 * 8));
loop {
interval.tick().await;
check_app_version(&data, &rx_health).await;
check_app_version(&data, &rx_health, &mut last_version_notification).await;
}
}

async fn check_app_version(
data: &web::Data<AppState>,
rx_health: &Receiver<Option<QuorumHealthState>>,
last_version_notification: &mut Option<Version>,
) {
// will return None in a non-HA deployment
if let Some(is_ha_leader) = is_ha_leader(rx_health) {
Expand All @@ -551,19 +555,29 @@ async fn check_app_version(
let this_version = semver::Version::parse(RAUTHY_VERSION).unwrap();

if latest_version > this_version && latest_version.pre.is_empty() {
info!("A new Rauthy App Version is available: {}", latest_version);
let version_url = format!("v{} -> {}", latest_version, url);
if last_version_notification.as_ref() == Some(&latest_version) {
debug!(
"Notified about version {} already - skipping it",
latest_version
);
} else {
info!("A new Rauthy App Version is available: {}", latest_version);
let version_url = format!("v{} -> {}", latest_version, url);

if let Err(err) =
LatestAppVersion::upsert(data, latest_version.clone(), version_url.clone())
.await
{
error!("Saving LatestAppVersion into DB: {:?}", err);
}

if let Err(err) =
LatestAppVersion::upsert(data, latest_version, version_url.clone()).await
{
error!("Saving LatestAppVersion into DB: {:?}", err);
}
data.tx_events
.send_async(Event::new_rauthy_version(version_url))
.await
.unwrap();

data.tx_events
.send_async(Event::new_rauthy_version(version_url))
.await
.unwrap();
*last_version_notification = Some(latest_version);
}
} else {
debug!("No new Rauthy App Version available");
}
Expand Down

0 comments on commit be19735

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/sebadob/rauthy/commit/be197355437d0338041cc3206421ec638ca938d7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy