Made the number of threads used by the built in http server configurable. Default is as many cpu cores

This commit is contained in:
emeric
2020-10-17 22:30:03 +02:00
parent c04f57ceb5
commit 5a6abdcba9
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -31,6 +31,9 @@ approot = "/usr/share/lms/approot";
# Location for deployment (See README if you want to deploy on a non root path)
deploy-path = "/";
# Number of threads to be used to dispatch http requests (0 means auto detect)
http-server-thread-count = 0;
# Acoustic brainz's root API
acousticbrainz-api-url = "https://acousticbrainz.org/api/v1/";
+8
View File
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <thread>
#include <boost/property_tree/xml_parser.hpp>
#include <Wt/WServer.h>
@@ -47,6 +49,7 @@ generateWtConfig(std::string execPath)
const std::filesystem::path wtLogFilePath {Service<IConfig>::get()->getPath("log-file", "/var/log/lms.log")};
const std::filesystem::path wtAccessLogFilePath {Service<IConfig>::get()->getPath("access-log-file", "/var/log/lms.access.log")};
const std::filesystem::path wtResourcesPath {Service<IConfig>::get()->getPath("wt-resources", "/usr/share/Wt/resources")};
const unsigned long configHttpServerThreadCount {Service<IConfig>::get()->getULong("http-server-thread-count", 0)};
args.push_back(execPath);
args.push_back("--config=" + wtConfigPath.string());
@@ -81,6 +84,11 @@ generateWtConfig(std::string execPath)
pt.put("server.application-settings.log-config", Service<IConfig>::get()->getString("log-config", "* -debug -info:WebRequest"));
pt.put("server.application-settings.behind-reverse-proxy", Service<IConfig>::get()->getBool("behind-reverse-proxy", false));
{
const unsigned long httpServerThreadCount {configHttpServerThreadCount ? configHttpServerThreadCount : std::max<unsigned long>(1, std::thread::hardware_concurrency())};
pt.put("server.application-settings.num-threads", httpServerThreadCount);
}
{
boost::property_tree::ptree viewport;
viewport.put("<xmlattr>.name", "viewport");