From 05c92e652ca84d6da4316462346c0da2c8bed601 Mon Sep 17 00:00:00 2001 From: Matthew Fioravante Date: Fri, 6 Oct 2017 05:54:52 +0000 Subject: [PATCH 1/2] Report TCPServer errorString() if webui fails to listen to port --- src/webui/webui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webui/webui.cpp b/src/webui/webui.cpp index 32795b7a5..82aa3a839 100644 --- a/src/webui/webui.cpp +++ b/src/webui/webui.cpp @@ -93,7 +93,7 @@ void WebUI::init() if (success) logger->addMessage(tr("Web UI: Now listening on port %1").arg(m_port)); else - logger->addMessage(tr("Web UI: Unable to bind to port %1").arg(m_port), Log::CRITICAL); + logger->addMessage(tr("Web UI: Unable to bind to port %1 : %2").arg(m_port).arg(m_httpServer->errorString()), Log::CRITICAL); } // DynDNS From 5185eeb7ef3266f3432fd5241400d65264a0bc70 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 8 Oct 2017 14:01:02 +0800 Subject: [PATCH 2/2] Die gracefully when failed to initialize web server with qbt-nox --- src/webui/webui.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/webui/webui.cpp b/src/webui/webui.cpp index 82aa3a839..96213c397 100644 --- a/src/webui/webui.cpp +++ b/src/webui/webui.cpp @@ -28,6 +28,10 @@ #include "webui.h" +#ifdef DISABLE_GUI +#include +#endif + #include "base/http/server.h" #include "base/logger.h" #include "base/net/dnsupdater.h" @@ -90,10 +94,17 @@ void WebUI::init() if (!m_httpServer->isListening()) { bool success = m_httpServer->listen(QHostAddress::Any, m_port); - if (success) + if (success) { logger->addMessage(tr("Web UI: Now listening on port %1").arg(m_port)); - else - logger->addMessage(tr("Web UI: Unable to bind to port %1 : %2").arg(m_port).arg(m_httpServer->errorString()), Log::CRITICAL); + } + else { + const QString errorMsg = tr("Web UI: Unable to bind to port %1. %2").arg(m_port).arg(m_httpServer->errorString()); + logger->addMessage(errorMsg, Log::CRITICAL); +#ifdef DISABLE_GUI + qCritical() << errorMsg; + QCoreApplication::exit(1); +#endif + } } // DynDNS