Add thread cli option
This commit is contained in:
parent
d2ad27ea3b
commit
7e8f1e30b7
@ -28,7 +28,7 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
app.port(flags->port)
|
app.port(flags->port)
|
||||||
.server_name(flags->name)
|
.server_name(flags->name)
|
||||||
.multithreaded();
|
.concurrency(flags->threads);
|
||||||
|
|
||||||
delete flags;
|
delete flags;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ void help(char* progName){
|
|||||||
std::cout << " [-n NAME] Server name (Default \"proc-api\")\n";
|
std::cout << " [-n NAME] Server name (Default \"proc-api\")\n";
|
||||||
std::cout << " [-a PATH] Path to file containing authorization tokens\n";
|
std::cout << " [-a PATH] Path to file containing authorization tokens\n";
|
||||||
std::cout << " If the -a flag is not passed, no authorization is used\n";
|
std::cout << " If the -a flag is not passed, no authorization is used\n";
|
||||||
|
std::cout << " [-t THREADS] Number of threads to use. By default, uses 2 threads\n";
|
||||||
std::cout << " [-h] Display this help message\n\n";
|
std::cout << " [-h] Display this help message\n\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -23,6 +24,7 @@ option_flags* parse_options(int argc, char** argv){
|
|||||||
option_flags* ret = new option_flags;
|
option_flags* ret = new option_flags;
|
||||||
|
|
||||||
ret->port = 5000;
|
ret->port = 5000;
|
||||||
|
ret->threads = 2;
|
||||||
ret->name = "proc-api";
|
ret->name = "proc-api";
|
||||||
ret->auth_path = "";
|
ret->auth_path = "";
|
||||||
|
|
||||||
@ -37,6 +39,11 @@ option_flags* parse_options(int argc, char** argv){
|
|||||||
case 'a':
|
case 'a':
|
||||||
ret->auth_path = std::string(optarg);
|
ret->auth_path = std::string(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
ret->threads = atoi(optarg);
|
||||||
|
if(ret->threads == 0)
|
||||||
|
ret->threads = 1;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
std::cerr << "Unkown option: " << (char)optopt << "\n";
|
std::cerr << "Unkown option: " << (char)optopt << "\n";
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// cli options
|
// cli options
|
||||||
|
|
||||||
constexpr char optarg_string[] = "n:p:a:h";
|
constexpr char optarg_string[] = "n:p:a:t:h";
|
||||||
|
|
||||||
struct option_flags {
|
struct option_flags {
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
uint16_t threads;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string auth_path;
|
std::string auth_path;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user