From 45f19f2633e215ad04ea4828093e997cd025e560 Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Mon, 2 Jan 2017 14:13:04 +0200 Subject: [PATCH] main: better error message on failing to start Prometheus Previously, if the Prometheus port (by default, 0.0.0.0:9180) could not be opened, the following message appeared in the log about 10 seconds into the run, and Scylla crashed. ERROR 2017-01-01 19:31:04,066 [shard 0] seastar - Exiting on unhandled exception: std::system_error (error system:98, Address already in use) The puzzled user would have no idea *which* address was already in use, why, or why Scylla stopped. In this patch, before the above message we get the much more informative message: ERROR 2017-01-01 19:58:19,080 [shard 0] init - Could not start Prometheus API server on 0.0.0.0:9180: std::system_error (error system:98, Address already in use) We continue to print the original message - and exit - in this case, under the assumption that it's better not to run the database while improperly configured. Signed-off-by: Nadav Har'El Message-Id: <20170102121304.2060-1-nyh@scylladb.com> --- main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.cc b/main.cc index 1748adda7c..fce5553406 100644 --- a/main.cc +++ b/main.cc @@ -689,7 +689,10 @@ int main(int ac, char** av) { pctx.prefix = cfg->prometheus_prefix(); prometheus_server.start().get(); prometheus::start(prometheus_server, pctx); - prometheus_server.listen(ipv4_addr{prom_addr.addresses[0].in.s_addr, pport}).get(); + prometheus_server.listen(ipv4_addr{prom_addr.addresses[0].in.s_addr, 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