diff --git a/src/main.rs b/src/main.rs index 83b3a92..e8b47a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ async fn update(headers: HeaderMap) -> &'static str { match updater::update().await { Ok(_) => log::info!("Updated!"), Err(err) => log::info!("Updater err: {:?}", err), - } + }; }); "Update started" diff --git a/src/updater.rs b/src/updater.rs index 3d99149..0ff582b 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -259,7 +259,16 @@ async fn send_webhooks() -> Result<(), Box> { Ok(()) } +lazy_static! { + pub static ref UPDATE_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::new(()); +} + pub async fn update() -> Result<(), Box> { + let _lock = match UPDATE_LOCK.try_lock() { + Ok(v) => v, + Err(err) => return Err(Box::new(err)), + }; + log::info!("Start update..."); let pool = match get_postgres_pool().await {