diff --git a/src/main.rs b/src/main.rs index 55f18cd..bf99592 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,7 +115,7 @@ async fn set_usage_msg(report_service: &Endpoint, activity_id: &str, current_usa }) .await { - Ok(Ok(())) => log::debug!("Successfully sent activity usage message"), + Ok(Ok(())) => log::trace!("Successfully sent activity usage message"), Ok(Err(rpc_message_error)) => { log::error!("rpcMessageError : {:?}", rpc_message_error) } diff --git a/src/process/automatic/monitor.rs b/src/process/automatic/monitor.rs index bccf67d..7c4b976 100644 --- a/src/process/automatic/monitor.rs +++ b/src/process/automatic/monitor.rs @@ -2,7 +2,6 @@ use crate::process::OutputLines; use super::*; -use reqwest::Client; use std::sync::Arc; use tokio::sync::oneshot::{self}; use tokio::task::JoinHandle; @@ -11,8 +10,6 @@ use tokio_stream::StreamExt; pub(super) struct OutputMonitor { #[allow(dead_code)] output_task: Arc>, - #[allow(dead_code)] - pinger_task: Arc>, } impl OutputMonitor { @@ -23,17 +20,12 @@ impl OutputMonitor { config: config.clone(), }; let output_task = Arc::new(spawn_output_monitoring(lines, output_handler)); - // Repetitive calling Automatic API triggers flushing Automatic process `stdout`. - let pinger_task = Arc::new(spawn_api_pinger(config.clone())); on_startup_rx .await .context("Automatic failed on startup")??; - Ok(Self { - output_task, - pinger_task, - }) + Ok(Self { output_task }) } } @@ -53,30 +45,6 @@ fn spawn_output_monitoring( }) } -/// Repetitive calling Automatic API triggers flushing process `stdout`. -/// It is required to log it, to monitor Automatic startup, and its shutdown. -/// When Automatic is started from console its output gets flushed. -/// Description and solution idea for faced issue https://stackoverflow.com/a/39528785/2608409 -fn spawn_api_pinger(config: Config) -> JoinHandle<()> { - log::debug!("Starting API pinger"); - let url = format!("http://{}:{}", config.api_host, config.api_port); - let client = Client::new().get(url); - tokio::spawn(async move { - loop { - let Some(client) = client.try_clone() else { - log::error!("Unable ping API"); - break; - }; - log::trace!("Pinging API"); - match client.send().await { - Ok(response) => log::trace!("Ping respone: {response:?}"), - Err(err) => log::warn!("Ping failure: {err:?}"), - }; - tokio::time::sleep(config.api_ping_delay).await; - } - }) -} - enum OutputHandler { LookingForStartup { //TODO create a custom error type?