feat: add local doctor checks
This commit is contained in:
parent
619e8eee62
commit
12e6815f8d
7 changed files with 409 additions and 7 deletions
|
|
@ -372,6 +372,7 @@ pub enum Command {
|
|||
#[command(subcommand)]
|
||||
command: BackupCommand,
|
||||
},
|
||||
Doctor,
|
||||
Node {
|
||||
#[command(subcommand)]
|
||||
command: NodeCommand,
|
||||
|
|
@ -1341,6 +1342,15 @@ async fn run_inner(cli: Cli) -> Result<()> {
|
|||
run_backup_command(&paths, command, cli.json || cli.jsonl)
|
||||
.context("run backup command")?;
|
||||
}
|
||||
Command::Doctor => {
|
||||
let report = geth_node::doctor::run_doctor(&paths)
|
||||
.await
|
||||
.context("run doctor")?;
|
||||
print_doctor_report(&report, cli.json || cli.jsonl)?;
|
||||
if !report.ok {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Command::Ssh {
|
||||
command:
|
||||
SshCommand::Proxy {
|
||||
|
|
@ -2241,6 +2251,7 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
| Command::Init { .. }
|
||||
| Command::Daemon { .. }
|
||||
| Command::Backup { .. }
|
||||
| Command::Doctor
|
||||
| Command::Wait { .. } => {
|
||||
bail!("command is handled directly")
|
||||
}
|
||||
|
|
@ -2316,6 +2327,29 @@ fn run_backup_command(paths: &GethPaths, command: BackupCommand, json: bool) ->
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn print_doctor_report(report: &geth_node::doctor::DoctorReport, json: bool) -> Result<()> {
|
||||
if json {
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&serde_json::json!({
|
||||
"type": "doctor",
|
||||
"ok": report.ok,
|
||||
"checks": report.checks,
|
||||
}))?
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("doctor: {}", if report.ok { "ok" } else { "failed" });
|
||||
for check in &report.checks {
|
||||
println!("{:?}\t{}\t{}", check.status, check.code, check.message);
|
||||
if let Some(hint) = &check.hint {
|
||||
println!("hint\t{}\t{}", check.code, hint);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_wait_command(paths: &GethPaths, command: WaitCommand) -> Result<WaitReport> {
|
||||
match command {
|
||||
WaitCommand::Daemon {
|
||||
|
|
|
|||
Loading…
Reference in a new issue