add sync_cert method to domain manager
This commit is contained in:
parent
6da68dc042
commit
dbc912a9d3
@ -125,6 +125,11 @@ pub trait Manager: Sync + Send {
|
||||
domain: &domain::Name,
|
||||
) -> Result<sync::Arc<dyn origin::Origin>, GetOriginError>;
|
||||
|
||||
fn sync_cert<'mgr>(
|
||||
&'mgr self,
|
||||
domain: domain::Name,
|
||||
) -> pin::Pin<Box<dyn future::Future<Output = Result<(), unexpected::Error>> + 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<Box<dyn future::Future<Output = Result<(), unexpected::Error>> + 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(())
|
||||
})
|
||||
|
11
src/main.rs
11
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!(
|
||||
|
Loading…
Reference in New Issue
Block a user