mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-16 20:08:09 +00:00
simplify config update notification (#683)
This commit is contained in:
@ -154,18 +154,14 @@ impl Config {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update(&mut self) -> Result<bool> {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,8 @@ async fn restart_systemd() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update(data: &ConfigData) -> Result<bool> {
|
||||
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<bool> {
|
||||
|
||||
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<bool> {
|
||||
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<bool> {
|
||||
info!("adding service {}", file_name);
|
||||
tokio::fs::write(&path, content).await?;
|
||||
start_service(&file_name).await?;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(changed)
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user