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