watchtower now uses cli-config/
This commit is contained in:
parent
756ba07b16
commit
74e7da214a
|
@ -4589,6 +4589,7 @@ dependencies = [
|
||||||
"reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"solana-clap-utils 1.1.0",
|
"solana-clap-utils 1.1.0",
|
||||||
|
"solana-cli-config 1.1.0",
|
||||||
"solana-client 1.1.0",
|
"solana-client 1.1.0",
|
||||||
"solana-logger 1.1.0",
|
"solana-logger 1.1.0",
|
||||||
"solana-metrics 1.1.0",
|
"solana-metrics 1.1.0",
|
||||||
|
|
|
@ -14,6 +14,7 @@ log = "0.4.8"
|
||||||
reqwest = { version = "0.10.1", default-features = false, features = ["blocking", "rustls-tls", "json"] }
|
reqwest = { version = "0.10.1", default-features = false, features = ["blocking", "rustls-tls", "json"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.1.0" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.1.0" }
|
||||||
|
solana-cli-config = { path = "../cli-config", version = "1.1.0" }
|
||||||
solana-client = { path = "../client", version = "1.1.0" }
|
solana-client = { path = "../client", version = "1.1.0" }
|
||||||
solana-logger = { path = "../logger", version = "1.1.0" }
|
solana-logger = { path = "../logger", version = "1.1.0" }
|
||||||
solana-metrics = { path = "../metrics", version = "1.1.0" }
|
solana-metrics = { path = "../metrics", version = "1.1.0" }
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
mod notifier;
|
mod notifier;
|
||||||
|
|
||||||
use crate::notifier::Notifier;
|
use crate::notifier::Notifier;
|
||||||
use clap::{crate_description, crate_name, value_t_or_exit, App, Arg};
|
use clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg};
|
||||||
use log::*;
|
use log::*;
|
||||||
use solana_clap_utils::{
|
use solana_clap_utils::{
|
||||||
input_parsers::pubkey_of,
|
input_parsers::pubkey_of,
|
||||||
input_validators::{is_pubkey_or_keypair, is_url},
|
input_validators::{is_pubkey_or_keypair, is_url},
|
||||||
};
|
};
|
||||||
|
use solana_cli_config::{Config, CONFIG_FILE};
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
use solana_metrics::{datapoint_error, datapoint_info};
|
use solana_metrics::{datapoint_error, datapoint_info};
|
||||||
use std::{error, io, thread::sleep, time::Duration};
|
use std::{error, io, thread::sleep, time::Duration};
|
||||||
|
@ -17,12 +18,25 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
let matches = App::new(crate_name!())
|
let matches = App::new(crate_name!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.version(solana_clap_utils::version!())
|
.version(solana_clap_utils::version!())
|
||||||
|
.arg({
|
||||||
|
let arg = Arg::with_name("config_file")
|
||||||
|
.short("C")
|
||||||
|
.long("config")
|
||||||
|
.value_name("PATH")
|
||||||
|
.takes_value(true)
|
||||||
|
.global(true)
|
||||||
|
.help("Configuration file to use");
|
||||||
|
if let Some(ref config_file) = *CONFIG_FILE {
|
||||||
|
arg.default_value(&config_file)
|
||||||
|
} else {
|
||||||
|
arg
|
||||||
|
}
|
||||||
|
})
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("json_rpc_url")
|
Arg::with_name("json_rpc_url")
|
||||||
.long("url")
|
.long("url")
|
||||||
.value_name("URL")
|
.value_name("URL")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
|
||||||
.validator(is_url)
|
.validator(is_url)
|
||||||
.help("JSON RPC URL for the cluster"),
|
.help("JSON RPC URL for the cluster"),
|
||||||
)
|
)
|
||||||
|
@ -50,14 +64,22 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
|
let config = if let Some(config_file) = matches.value_of("config_file") {
|
||||||
|
Config::load(config_file).unwrap_or_default()
|
||||||
|
} else {
|
||||||
|
Config::default()
|
||||||
|
};
|
||||||
|
|
||||||
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
|
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
|
||||||
let json_rpc_url = value_t_or_exit!(matches, "json_rpc_url", String);
|
let json_rpc_url =
|
||||||
|
value_t!(matches, "json_rpc_url", String).unwrap_or_else(|_| config.json_rpc_url);
|
||||||
let validator_identity = pubkey_of(&matches, "validator_identity").map(|i| i.to_string());
|
let validator_identity = pubkey_of(&matches, "validator_identity").map(|i| i.to_string());
|
||||||
let no_duplicate_notifications = matches.is_present("no_duplicate_notifications");
|
let no_duplicate_notifications = matches.is_present("no_duplicate_notifications");
|
||||||
|
|
||||||
solana_logger::setup_with_default("solana=info");
|
solana_logger::setup_with_default("solana=info");
|
||||||
solana_metrics::set_panic_hook("watchtower");
|
solana_metrics::set_panic_hook("watchtower");
|
||||||
|
|
||||||
|
info!("RPC URL: {}", json_rpc_url);
|
||||||
let rpc_client = RpcClient::new(json_rpc_url);
|
let rpc_client = RpcClient::new(json_rpc_url);
|
||||||
|
|
||||||
let notifier = Notifier::new();
|
let notifier = Notifier::new();
|
||||||
|
|
Loading…
Reference in New Issue