diff --git a/edge-modules/api-proxy-module/src/main.rs b/edge-modules/api-proxy-module/src/main.rs index bd5cf16c592..4e8190f4f76 100644 --- a/edge-modules/api-proxy-module/src/main.rs +++ b/edge-modules/api-proxy-module/src/main.rs @@ -19,6 +19,7 @@ use tokio::{ process::{Child, Command}, sync::Notify, task::JoinHandle, + time, }; use api_proxy_module::{ @@ -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(); @@ -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); } } });