Skip to content

Commit

Permalink
add metrics endpoint port conflict hint
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Dec 17, 2020
1 parent 68a078a commit abfe4f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion zebra-network/src/peer_set/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ where
Err(_) => panic!(
"{} {} {}",
"Listener failed. Port already in use.",
"Is another instance of zebrad or zcashd running in your local machine ?",
"Is another instance of zebrad or zcashd running in your local machine?",
"Consider changing the default port in the configuration file."
),
};
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/finalized_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl FinalizedState {
Ok(d) => d,
Err(_) => panic!(
"{} {}",
"LOCK file in use.", "Check if there is antoher zebrad process running."
"LOCK file already in use.", "Check if there is antoher zebrad process running."
),
};

Expand Down
3 changes: 1 addition & 2 deletions zebrad/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ impl Application for ZebradApp {
Some(as_string) => as_string,
None => return true,
};
!error_str.contains("Port already in use")
&& !error_str.contains("LOCK file in use")
!error_str.contains("already in use")
}
color_eyre::ErrorKind::Recoverable(error) => {
// type checks should be faster than string conversions
Expand Down
14 changes: 11 additions & 3 deletions zebrad/src/components/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ impl MetricsEndpoint {
pub fn new(config: &ZebradConfig) -> Result<Self, FrameworkError> {
if let Some(addr) = config.metrics.endpoint_addr {
info!("Initializing metrics endpoint at {}", addr);
metrics_exporter_prometheus::PrometheusBuilder::new()
let check_endpoint = metrics_exporter_prometheus::PrometheusBuilder::new()
.listen_address(addr)
.install()
.expect("FIXME ERROR CONVERSION");
.install();
match check_endpoint {
Ok(endpoint) => endpoint,
Err(_) => panic!(
"{} {} {}",
"Port for metrics endpoint already in use by another process:",
addr,
"- You can change the metrics default endpoint in the config."
),
}
}
Ok(Self {})
}
Expand Down

0 comments on commit abfe4f6

Please sign in to comment.