http: enable running prometheus endpoint

This commit is contained in:
Joakim Frostegård 2023-01-18 21:05:20 +01:00
parent 32884aae36
commit b41c565e38

View file

@ -1,3 +1,4 @@
use anyhow::Context;
use aquatic_common::{ use aquatic_common::{
access_list::update_access_list, access_list::update_access_list,
cpu_pinning::{ cpu_pinning::{
@ -30,6 +31,21 @@ const SHARED_CHANNEL_SIZE: usize = 1024;
pub fn run(config: Config) -> ::anyhow::Result<()> { pub fn run(config: Config) -> ::anyhow::Result<()> {
let mut signals = Signals::new([SIGUSR1, SIGTERM])?; let mut signals = Signals::new([SIGUSR1, SIGTERM])?;
#[cfg(feature = "prometheus")]
if config.metrics.run_prometheus_endpoint {
use metrics_exporter_prometheus::PrometheusBuilder;
PrometheusBuilder::new()
.with_http_listener(config.metrics.prometheus_endpoint_address)
.install()
.with_context(|| {
format!(
"Install prometheus endpoint on {}",
config.metrics.prometheus_endpoint_address
)
})?;
}
let state = State::default(); let state = State::default();
update_access_list(&config.access_list, &state.access_list)?; update_access_list(&config.access_list, &state.access_list)?;