Remove refresh functionality that causes dashboard to hang
- Remove 'r' key handler that was causing hang on refresh - Remove RefreshRequested event and check_refresh_request method - Remove send_refresh_commands function and ZMQ command protocol - Remove refresh_requested field from App struct - Clean up status line text (refresh -> tick) The refresh functionality was causing the dashboard to become unresponsive when pressing 'r' key. This removes all refresh-related code to fix the issue.
This commit is contained in:
parent
cfc89e7312
commit
7a664ef0fb
@ -69,7 +69,6 @@ pub struct App {
|
|||||||
active_host_index: usize,
|
active_host_index: usize,
|
||||||
show_help: bool,
|
show_help: bool,
|
||||||
should_quit: bool,
|
should_quit: bool,
|
||||||
refresh_requested: bool,
|
|
||||||
last_tick: Instant,
|
last_tick: Instant,
|
||||||
tick_count: u64,
|
tick_count: u64,
|
||||||
status: String,
|
status: String,
|
||||||
@ -107,7 +106,6 @@ impl App {
|
|||||||
active_host_index: 0,
|
active_host_index: 0,
|
||||||
show_help: false,
|
show_help: false,
|
||||||
should_quit: false,
|
should_quit: false,
|
||||||
refresh_requested: false,
|
|
||||||
last_tick: Instant::now(),
|
last_tick: Instant::now(),
|
||||||
tick_count: 0,
|
tick_count: 0,
|
||||||
status,
|
status,
|
||||||
@ -124,7 +122,7 @@ impl App {
|
|||||||
let host_count = self.hosts.len();
|
let host_count = self.hosts.len();
|
||||||
let retention = self.history.retention();
|
let retention = self.history.retention();
|
||||||
self.status = format!(
|
self.status = format!(
|
||||||
"Monitoring • hosts: {} • refresh: {:?} • retention: {:?}",
|
"Monitoring • hosts: {} • tick: {:?} • retention: {:?}",
|
||||||
host_count, self.options.tick_rate, retention
|
host_count, self.options.tick_rate, retention
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -139,10 +137,6 @@ impl App {
|
|||||||
self.should_quit = true;
|
self.should_quit = true;
|
||||||
self.status = "Exiting…".to_string();
|
self.status = "Exiting…".to_string();
|
||||||
}
|
}
|
||||||
KeyCode::Char('r') | KeyCode::Char('R') => {
|
|
||||||
self.refresh_requested = true;
|
|
||||||
self.status = "Refresh requested - sending commands to agents...".to_string();
|
|
||||||
}
|
|
||||||
KeyCode::Left | KeyCode::Char('h') => {
|
KeyCode::Left | KeyCode::Char('h') => {
|
||||||
self.select_previous_host();
|
self.select_previous_host();
|
||||||
}
|
}
|
||||||
@ -160,14 +154,6 @@ impl App {
|
|||||||
self.should_quit
|
self.should_quit
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_refresh_request(&mut self) -> bool {
|
|
||||||
if self.refresh_requested {
|
|
||||||
self.refresh_requested = false;
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn status_text(&self) -> &str {
|
pub fn status_text(&self) -> &str {
|
||||||
@ -353,10 +339,6 @@ impl App {
|
|||||||
|
|
||||||
self.status = format!("Fetch failed • host: {} • {}", host, error);
|
self.status = format!("Fetch failed • host: {} • {}", host, error);
|
||||||
}
|
}
|
||||||
AppEvent::RefreshRequested => {
|
|
||||||
// Handle refresh command - will be implemented in the main loop
|
|
||||||
self.status = "Refresh command sent to all agents".to_string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,6 +643,5 @@ pub enum AppEvent {
|
|||||||
error: String,
|
error: String,
|
||||||
timestamp: DateTime<Utc>,
|
timestamp: DateTime<Utc>,
|
||||||
},
|
},
|
||||||
RefreshRequested,
|
|
||||||
Shutdown,
|
Shutdown,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ struct Cli {
|
|||||||
#[arg(short = 'H', long, value_name = "HOST")]
|
#[arg(short = 'H', long, value_name = "HOST")]
|
||||||
host: Option<String>,
|
host: Option<String>,
|
||||||
|
|
||||||
/// Interval (ms) to refresh dashboard when idle
|
/// Interval (ms) for dashboard tick rate
|
||||||
#[arg(long, default_value_t = 250)]
|
#[arg(long, default_value_t = 250)]
|
||||||
tick_rate: u64,
|
tick_rate: u64,
|
||||||
|
|
||||||
@ -154,10 +154,6 @@ fn run_app(
|
|||||||
while !app.should_quit() {
|
while !app.should_quit() {
|
||||||
drain_app_events(app, event_rx);
|
drain_app_events(app, event_rx);
|
||||||
|
|
||||||
// Check for refresh requests
|
|
||||||
if app.check_refresh_request() {
|
|
||||||
send_refresh_commands(app)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
terminal.draw(|frame| ui::render(frame, app))?;
|
terminal.draw(|frame| ui::render(frame, app))?;
|
||||||
|
|
||||||
@ -307,57 +303,6 @@ fn metrics_blocking_loop(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_refresh_commands(app: &mut App) -> Result<()> {
|
|
||||||
let endpoints = app.zmq_endpoints();
|
|
||||||
if endpoints.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let zmq_context = NativeZmqContext::new();
|
|
||||||
|
|
||||||
for endpoint in endpoints {
|
|
||||||
// Convert metrics endpoint (6130) to command endpoint (6131)
|
|
||||||
let command_endpoint = endpoint.replace(":6130", ":6131");
|
|
||||||
|
|
||||||
let socket = zmq_context.socket(zmq::REQ)?;
|
|
||||||
socket.set_linger(0)?;
|
|
||||||
socket.set_rcvtimeo(5000)?; // 5 second timeout
|
|
||||||
socket.set_sndtimeo(5000)?; // 5 second timeout
|
|
||||||
|
|
||||||
match socket.connect(&command_endpoint) {
|
|
||||||
Ok(()) => {
|
|
||||||
debug!("Sending refresh command to {}", command_endpoint);
|
|
||||||
|
|
||||||
match socket.send("refresh", 0) {
|
|
||||||
Ok(()) => {
|
|
||||||
// Wait for response
|
|
||||||
match socket.recv_string(0) {
|
|
||||||
Ok(Ok(response)) => {
|
|
||||||
debug!("Refresh response from {}: {}", command_endpoint, response);
|
|
||||||
// Update status via public method would be needed, for now just log
|
|
||||||
debug!("Refresh sent to agents - response: {}", response);
|
|
||||||
}
|
|
||||||
Ok(Err(e)) => {
|
|
||||||
warn!("String conversion error from {}: {:?}", command_endpoint, e);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
warn!("No response from {}: {}", command_endpoint, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
warn!("Failed to send refresh to {}: {}", command_endpoint, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
warn!("Failed to connect to command endpoint {}: {}", command_endpoint, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_zmq_message(
|
fn handle_zmq_message(
|
||||||
message: &NativeZmqMessage,
|
message: &NativeZmqMessage,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user