diff --git a/src/domain/manager.rs b/src/domain/manager.rs index 00afda2..0353de7 100644 --- a/src/domain/manager.rs +++ b/src/domain/manager.rs @@ -125,6 +125,11 @@ pub trait Manager: Sync + Send { domain: &domain::Name, ) -> Result, GetOriginError>; + fn sync_cert<'mgr>( + &'mgr self, + domain: domain::Name, + ) -> pin::Pin> + Send + 'mgr>>; + fn sync_with_config<'mgr>( &'mgr self, domain: domain::Name, @@ -223,6 +228,20 @@ impl Manager for ManagerImpl { Ok(origin) } + fn sync_cert<'mgr>( + &'mgr self, + domain: domain::Name, + ) -> pin::Pin> + Send + 'mgr>> + { + Box::pin(async move { + if let Some(ref acme_manager) = self.acme_manager { + acme_manager.sync_domain(domain.clone()).await?; + } + + Ok(()) + }) + } + fn sync_with_config<'mgr>( &'mgr self, domain: domain::Name, @@ -243,9 +262,7 @@ impl Manager for ManagerImpl { self.domain_config_store.set(&domain, &config)?; - if let Some(ref acme_manager) = self.acme_manager { - acme_manager.sync_domain(domain.clone()).await?; - } + self.sync_cert(domain).await?; Ok(()) }) diff --git a/src/main.rs b/src/main.rs index 1360c7a..4a4a995 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,6 @@ async fn main() { if let Some(https_params) = https_params { // Periodically refresh all domain certs, including the http_domain passed in the Cli opts wait_group.push({ - let https_params = https_params.clone(); let domain_manager = domain_manager.clone(); let http_domain = config.http_domain.clone(); let canceller = canceller.clone(); @@ -219,9 +218,8 @@ async fn main() { _ = canceller.cancelled() => return, } - _ = https_params - .domain_acme_manager - .sync_domain(http_domain.clone()) + _ = domain_manager + .sync_cert(http_domain.clone()) .await .inspect_err(|err| { log::error!( @@ -238,9 +236,8 @@ async fn main() { } for domain in domains_iter.unwrap().into_iter() { - let _ = https_params - .domain_acme_manager - .sync_domain(domain.clone()) + let _ = domain_manager + .sync_cert(domain.clone()) .await .inspect_err(|err| { log::error!(