Made the number of threads used by the built in http server configurable. Default is as many cpu cores
This commit is contained in:
@@ -31,6 +31,9 @@ approot = "/usr/share/lms/approot";
|
|||||||
# Location for deployment (See README if you want to deploy on a non root path)
|
# Location for deployment (See README if you want to deploy on a non root path)
|
||||||
deploy-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
|
# Acoustic brainz's root API
|
||||||
acousticbrainz-api-url = "https://acousticbrainz.org/api/v1/";
|
acousticbrainz-api-url = "https://acousticbrainz.org/api/v1/";
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include <boost/property_tree/xml_parser.hpp>
|
#include <boost/property_tree/xml_parser.hpp>
|
||||||
|
|
||||||
#include <Wt/WServer.h>
|
#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 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 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 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(execPath);
|
||||||
args.push_back("--config=" + wtConfigPath.string());
|
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.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));
|
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;
|
boost::property_tree::ptree viewport;
|
||||||
viewport.put("<xmlattr>.name", "viewport");
|
viewport.put("<xmlattr>.name", "viewport");
|
||||||
|
|||||||
Reference in New Issue
Block a user