From 4e8d73098f5bcef96a456f89fef1820b7e00d3f6 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Thu, 9 Mar 2017 08:46:26 +0200 Subject: [PATCH] main: Prometheus should start as early as possible There is no need to wait when starting the prometheus server. As it is up to each of the modules to register its metrics when it is ready. This is especially important when debuging boot issues. This patch moves the prometheus initilization to be done at an early stage of the boot sequencec. Fixes #2144 Signed-off-by: Amnon Heiman Message-Id: <1489041986-28974-1-git-send-email-amnon@scylladb.com> --- main.cc | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/main.cc b/main.cc index 3dc619f3dc..391953695e 100644 --- a/main.cc +++ b/main.cc @@ -358,7 +358,19 @@ int main(int ac, char** av) { sstring api_address = cfg->api_address() != "" ? cfg->api_address() : rpc_address; sstring broadcast_address = cfg->broadcast_address(); sstring broadcast_rpc_address = cfg->broadcast_rpc_address(); - + auto prom_addr = seastar::net::dns::get_host_by_name(cfg->prometheus_address()).get0(); + supervisor::notify("starting prometheus API server"); + uint16_t pport = cfg->prometheus_port(); + if (pport) { + pctx.metric_help = "Scylla server statistics"; + pctx.prefix = cfg->prometheus_prefix(); + prometheus_server.start().get(); + prometheus::start(prometheus_server, pctx); + prometheus_server.listen(ipv4_addr{prom_addr.addr_list.front(), pport}).handle_exception([pport, &cfg] (auto ep) { + startlog.error("Could not start Prometheus API server on {}:{}: {}", cfg->prometheus_address(), pport, ep); + return make_exception_future<>(ep); + }).get(); + } if (!broadcast_address.empty()) { try { utils::fb_utilities::set_broadcast_address(gms::inet_address::lookup(broadcast_address).get0()); @@ -631,19 +643,6 @@ int main(int ac, char** av) { }).get(); } api::set_server_done(ctx).get(); - auto prom_addr = seastar::net::dns::get_host_by_name(cfg->prometheus_address()).get0(); - supervisor::notify("starting prometheus API server"); - uint16_t pport = cfg->prometheus_port(); - if (pport) { - pctx.metric_help = "Scylla server statistics"; - pctx.prefix = cfg->prometheus_prefix(); - prometheus_server.start().get(); - prometheus::start(prometheus_server, pctx); - prometheus_server.listen(ipv4_addr{prom_addr.addr_list.front(), pport}).handle_exception([pport, &cfg] (auto ep) { - startlog.error("Could not start Prometheus API server on {}:{}: {}", cfg->prometheus_address(), pport, ep); - return make_exception_future<>(ep); - }).get(); - } supervisor::notify("serving"); // Register at_exit last, so that storage_service::drain_on_shutdown will be called first engine().at_exit([] {