diff --git a/src/proxy-manager/src/config.rs b/src/proxy-manager/src/config.rs index e3899f37d..2dfa82ef6 100644 --- a/src/proxy-manager/src/config.rs +++ b/src/proxy-manager/src/config.rs @@ -154,18 +154,14 @@ impl Config { Ok(()) } - pub async fn update(&mut self) -> Result { + pub async fn update(&mut self) -> Result<()> { if self.fetch().await? { info!("config updated"); self.save().await?; + proxy::update(&self.data).await?; + self.notify().await?; } - let notified = if proxy::update(&self.data).await? { - self.notify().await?; - true - } else { - false - }; - Ok(notified) + Ok(()) } } diff --git a/src/proxy-manager/src/proxy.rs b/src/proxy-manager/src/proxy.rs index 10be5e015..54b241490 100644 --- a/src/proxy-manager/src/proxy.rs +++ b/src/proxy-manager/src/proxy.rs @@ -72,9 +72,8 @@ async fn restart_systemd() -> Result<()> { Ok(()) } -pub async fn update(data: &ConfigData) -> Result { +pub async fn update(data: &ConfigData) -> Result<()> { let configs = build(data); - let mut changed = false; let mut config_dir = tokio::fs::read_dir(SYSTEMD_CONFIG_DIR).await?; while let Some(entry) = config_dir.next().await { @@ -107,7 +106,6 @@ pub async fn update(data: &ConfigData) -> Result { tokio::fs::write(&path, configs[&file_name].clone()).await?; start_service(&file_name).await?; - changed = true; } } else { info!("stopping proxy {}", file_name); @@ -115,7 +113,6 @@ pub async fn update(data: &ConfigData) -> Result { tokio::fs::remove_file(&path).await?; stop_service(&file_name).await?; restart_systemd().await?; - changed = true; } } @@ -125,9 +122,8 @@ pub async fn update(data: &ConfigData) -> Result { info!("adding service {}", file_name); tokio::fs::write(&path, content).await?; start_service(&file_name).await?; - changed = true; } } - Ok(changed) + Ok(()) }