removed drecks loop
This commit is contained in:
@@ -124,7 +124,7 @@ pub async fn heartbeat_loop(base_url: &str, ip: &str) -> Result<(), Box<dyn Erro
|
|||||||
|
|
||||||
match client.post(&url).json(&payload).send().await {
|
match client.post(&url).json(&payload).send().await {
|
||||||
Ok(res) if res.status().is_success() => {
|
Ok(res) if res.status().is_success() => {
|
||||||
println!("Heartbeat sent successfully.");
|
println!("✅ Heartbeat sent successfully.");
|
||||||
}
|
}
|
||||||
Ok(res) => eprintln!("Server responded with status: {}", res.status()),
|
Ok(res) => eprintln!("Server responded with status: {}", res.status()),
|
||||||
Err(e) => eprintln!("Heartbeat error: {}", e),
|
Err(e) => eprintln!("Heartbeat error: {}", e),
|
||||||
@@ -140,20 +140,15 @@ pub async fn send_metrics(
|
|||||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let url = format!("{}/monitoring/metric", base_url);
|
let url = format!("{}/monitoring/metric", base_url);
|
||||||
let mut interval = interval(Duration::from_secs(20));
|
|
||||||
|
|
||||||
loop {
|
match client.post(&url).json(&metrics).send().await {
|
||||||
interval.tick().await;
|
Ok(res) => println!(
|
||||||
let metric = metrics;
|
"✅ Sent metrics for server {} | Status: {}",
|
||||||
eprintln!("Sending metrics: {:?}", metric);
|
metrics.server_id,
|
||||||
|
res.status()
|
||||||
match client.post(&url).json(&metric).send().await {
|
),
|
||||||
Ok(res) => println!(
|
Err(err) => eprintln!("❌ Failed to send metrics: {}", err),
|
||||||
"✅ Sent metrics for server {} | Status: {}",
|
|
||||||
metric.server_id,
|
|
||||||
res.status()
|
|
||||||
),
|
|
||||||
Err(err) => eprintln!("❌ Failed to send metrics: {}", err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user