feat(server): add local prom and health routes if running w/ ngrok

This commit is contained in:
OlivierDehaene 2023-07-21 16:56:30 +02:00
parent 15b3e9ffb0
commit 1da642bd0e
1 changed files with 142 additions and 127 deletions

View File

@ -683,10 +683,10 @@ pub async fn run(
// Prometheus metrics route
.route("/metrics", get(metrics))
.layer(Extension(info))
.layer(Extension(health_ext))
.layer(Extension(health_ext.clone()))
.layer(Extension(compat_return_full_text))
.layer(Extension(infer))
.layer(Extension(prom_handle))
.layer(Extension(prom_handle.clone()))
.layer(opentelemetry_tracing_layer())
.layer(cors_layer);
@ -712,6 +712,21 @@ pub async fn run(
let listener = tunnel.listen().await.unwrap();
// Run prom metrics and health locally too
tokio::spawn(
axum::Server::bind(&addr)
.serve(
Router::new()
.route("/health", get(health))
.route("/metrics", get(metrics))
.layer(Extension(health_ext))
.layer(Extension(prom_handle))
.into_make_service(),
)
//Wait until all requests are finished to shut down
.with_graceful_shutdown(shutdown_signal()),
);
// Run server
axum::Server::builder(listener)
.serve(app.into_make_service())