From 7dfcc7f2b9e0a07fe231aad0fa6fcd42fb309bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Mon, 20 Apr 2020 16:20:04 +0200 Subject: [PATCH] RESTAPI_Server is now also started with 'metrics' endpoint enabled in case of port change --- lib/ProxySQL_Admin.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index dea442753..f09b76d52 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -5599,17 +5599,17 @@ void ProxySQL_Admin::flush_admin_variables___database_to_runtime(SQLite3DB *db, //commit(); NOT IMPLEMENTED wrunlock(); { + std::function(const httpserver::http_request&)> prometheus_callback { + [this](const httpserver::http_request& request) { + auto headers = request_headers(request); + auto serial_response = this->serial_exposer(headers); + auto http_response = make_response(serial_response); + + return http_response; + } + }; if (variables.restapi_enabled != variables.restapi_enabled_old) { if (variables.restapi_enabled) { - std::function(const httpserver::http_request&)> prometheus_callback { - [this](const httpserver::http_request& request) { - auto headers = request_headers(request); - auto serial_response = this->serial_exposer(headers); - auto http_response = make_response(serial_response); - - return http_response; - } - }; AdminRestApiServer = new ProxySQL_RESTAPI_Server( variables.restapi_port, {{"/metrics", prometheus_callback}} ); @@ -5626,7 +5626,9 @@ void ProxySQL_Admin::flush_admin_variables___database_to_runtime(SQLite3DB *db, AdminRestApiServer = NULL; } if (variables.restapi_enabled) { - AdminRestApiServer = new ProxySQL_RESTAPI_Server(variables.restapi_port); + AdminRestApiServer = new ProxySQL_RESTAPI_Server( + variables.restapi_port, {{"/metrics", prometheus_callback}} + ); } variables.restapi_port_old = variables.restapi_port; }