diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index edc79b4..cb39c49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ mod cert_store; mod consul; mod http; mod https; +mod metrics; mod proxy_config; mod reverse_proxy; mod tls_util; @@ -80,6 +81,10 @@ struct Opt { )] pub https_bind_addr: SocketAddr, + /// Bind address for metrics server (Prometheus format over HTTP) + #[structopt(long = "metrics-bind-addr", env = "TRICOT_METRICS_BIND_ADDR")] + pub metrics_bind_addr: Option<SocketAddr>, + /// E-mail address for Let's Encrypt certificate requests #[structopt(long = "letsencrypt-email", env = "TRICOT_LETSENCRYPT_EMAIL")] pub letsencrypt_email: String, @@ -123,6 +128,8 @@ async fn main() { let _ = provoke_exit.send(true); }; + let metrics_server = metrics::MetricsServer::init(opt.metrics_bind_addr); + let consul_config = consul::ConsulConfig { addr: opt.consul_addr.clone(), ca_cert: opt.consul_ca_cert.clone(), @@ -143,6 +150,13 @@ async fn main() { exit_on_err.clone(), ); + let metrics_task = tokio::spawn( + metrics_server + .run(wait_from(exit_signal.clone())) + .map_err(exit_on_err.clone()) + .then(|_| async { info!("Metrics server exited") }), + ); + let http_task = tokio::spawn( http::serve_http( opt.http_bind_addr, @@ -176,6 +190,7 @@ async fn main() { let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone())); + let _ = metrics_task.await.expect("Tokio task await failure"); let _ = http_task.await.expect("Tokio task await failure"); let _ = https_task.await.expect("Tokio task await failure"); let _ = dump_task.await.expect("Tokio task await failure"); |