Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agave-validator: extract monitor #4762

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> {
.subcommand(
SubCommand::with_name("init").about("Initialize the ledger directory then exit"),
)
.subcommand(SubCommand::with_name("monitor").about("Monitor the validator"))
.subcommand(commands::monitor::command(default_args))
.subcommand(SubCommand::with_name("run").about("Run the validator"))
.subcommand(
SubCommand::with_name("plugin")
Expand Down
1 change: 1 addition & 0 deletions validator/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod authorized_voter;
pub mod monitor;
pub mod wait_for_restart_window;
25 changes: 25 additions & 0 deletions validator/src/commands/monitor/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use {
crate::{cli::DefaultArgs, dashboard::Dashboard},
clap::{App, ArgMatches, SubCommand},
std::{path::Path, process::exit, time::Duration},
};

pub fn command(_default_args: &DefaultArgs) -> App<'_, '_> {
SubCommand::with_name("monitor").about("Monitor the validator")
}

pub fn execute(_matches: &ArgMatches, ledger_path: &Path) {
monitor_validator(ledger_path);
}

pub fn monitor_validator(ledger_path: &Path) {
let dashboard = Dashboard::new(ledger_path, None, None).unwrap_or_else(|err| {
println!(
"Error: Unable to connect to validator at {}: {:?}",
ledger_path.display(),
err,
);
exit(1);
});
dashboard.run(Duration::from_secs(2));
}
20 changes: 3 additions & 17 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use {
admin_rpc_service::{load_staked_nodes_overrides, StakedNodesOverrides},
bootstrap,
cli::{self, app, warn_for_deprecated_arguments, DefaultArgs},
commands,
dashboard::Dashboard,
ledger_lockfile, lock_ledger, redirect_stderr_to_file,
commands, ledger_lockfile, lock_ledger, redirect_stderr_to_file,
},
clap::{crate_name, value_t, value_t_or_exit, values_t, values_t_or_exit, ArgMatches},
crossbeam_channel::unbounded,
Expand Down Expand Up @@ -98,18 +96,6 @@ enum Operation {

const MILLIS_PER_SECOND: u64 = 1000;

fn monitor_validator(ledger_path: &Path) {
let dashboard = Dashboard::new(ledger_path, None, None).unwrap_or_else(|err| {
println!(
"Error: Unable to connect to validator at {}: {:?}",
ledger_path.display(),
err,
);
exit(1);
});
dashboard.run(Duration::from_secs(2));
}

fn set_repair_whitelist(
ledger_path: &Path,
whitelist: Vec<Pubkey>,
Expand Down Expand Up @@ -337,12 +323,12 @@ pub fn main() {
println!("Exit request sent");

if monitor {
monitor_validator(&ledger_path);
commands::monitor::monitor_validator(&ledger_path);
}
return;
}
("monitor", _) => {
monitor_validator(&ledger_path);
commands::monitor::execute(&matches, &ledger_path);
return;
}
("staked-nodes-overrides", Some(subcommand_matches)) => {
Expand Down
Loading