Skip to content

Commit

Permalink
Add delay between nginx crashes (#5852)
Browse files Browse the repository at this point in the history
Added a delay between nginx restarts to avoid spamming the log file.

## Azure IoT Edge PR checklist:
  • Loading branch information
huguesBouvier authored Nov 29, 2021
1 parent 5015eca commit 2f6bfb3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions edge-modules/api-proxy-module/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use tokio::{
process::{Child, Command},
sync::Notify,
task::JoinHandle,
time,
};

use api_proxy_module::{
Expand All @@ -28,6 +29,8 @@ use api_proxy_module::{
};
use shutdown_handle::ShutdownHandle;

const MAX_LOOP_INTERVAL_SECONDS: tokio::time::Duration = tokio::time::Duration::from_secs(1);

#[tokio::main]
async fn main() -> Result<()> {
env_logger::builder().filter_level(LevelFilter::Info).init();
Expand Down Expand Up @@ -188,6 +191,10 @@ pub fn nginx_controller_start(
return Ok(());
}
}

// This delay controls how fast the main loop can reconnect once nginx crashed.
// Without this, nginx crashes and restart continuously. Rapidly increasing the size of the logs.
time::sleep(MAX_LOOP_INTERVAL_SECONDS);
}
}
});
Expand Down

0 comments on commit 2f6bfb3

Please sign in to comment.