From: Remi Gacogne Date: Thu, 3 Dec 2020 08:34:08 +0000 (+0100) Subject: rec: Handle failure to start the web server more gracefully X-Git-Tag: rec-4.5.0-alpha1~86^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9812%2Fhead;p=thirdparty%2Fpdns.git rec: Handle failure to start the web server more gracefully At this point we already have several threads so calling exit() will cause problem by trying to destruct objects that are in use by other threads, so call _exit() instead. Also mention the web server in the error message so that the root cause is easier to identify. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index f3a5d17d68..6c9e641e97 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3658,7 +3658,7 @@ static bool trySendingQueryToWorker(unsigned int target, ThreadMSG* tmsg) auto& targetInfo = s_threadInfos[target]; if(!targetInfo.isWorker) { g_log< T broadcastAccFunction(const boost::function& func) { if (!isHandlerThread()) { g_log<getName() << "' multiplexer"<(new AsyncWebServer(fdm, arg()["webserver-address"], arg().asNum("webserver-port"))); + d_ws = make_unique(fdm, arg()["webserver-address"], arg().asNum("webserver-port")); + d_ws->setApiKey(arg()["api-key"]); d_ws->setPassword(arg()["webserver-password"]); d_ws->setLogLevel(arg()["webserver-loglevel"]); @@ -534,8 +535,10 @@ RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm) d_ws->registerApiHandler("/api/v1/servers", &apiServer); d_ws->registerApiHandler("/api", &apiDiscovery); - for(const auto& u : g_urlmap) + for (const auto& u : g_urlmap) { d_ws->registerWebHandler("/"+u.first, serveStuff); + } + d_ws->registerWebHandler("/", serveStuff); d_ws->registerWebHandler("/metrics", prometheusMetrics); d_ws->go();