Modify the ConfigLoader.cc file
This commit is contained in:
parent
c9f842fe93
commit
8b461326d8
|
@ -47,8 +47,9 @@
|
|||
}
|
||||
],*/
|
||||
"app": {
|
||||
//threads_num:num of threads,1 by default
|
||||
"threads_num": 16,
|
||||
//threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads
|
||||
//will be the number of processors.
|
||||
"threads_num": 1,
|
||||
//enable_session:false by default
|
||||
"enable_session": false,
|
||||
"session_timeout": 0,
|
||||
|
@ -132,4 +133,4 @@
|
|||
//of the connection without read or write
|
||||
"idle_connection_timeout": 60
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
|
||||
using namespace drogon;
|
||||
|
||||
ConfigLoader::ConfigLoader(const std::string &configFile)
|
||||
|
@ -136,6 +138,14 @@ static void loadApp(const Json::Value &app)
|
|||
return;
|
||||
//threads number
|
||||
auto threadsNum = app.get("threads_num", 1).asUInt64();
|
||||
if (threadsNum == 0)
|
||||
{
|
||||
//set the number to the number of processors.
|
||||
threadsNum = std::thread::hardware_concurrency();
|
||||
LOG_DEBUG << "The number of processors is " << threadsNum;
|
||||
}
|
||||
if (threadsNum < 1)
|
||||
threadsNum = 1;
|
||||
drogon::app().setThreadNum(threadsNum);
|
||||
//session
|
||||
auto enableSession = app.get("enable_session", false).asBool();
|
||||
|
|
Loading…
Reference in New Issue