28
28
#endif
29
29
30
30
void RunServer () {
31
+ #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
32
+ signal (SIGINT, SIG_IGN);
33
+ #elif defined(_WIN32)
34
+ auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL {
35
+ return (ctrl_type == CTRL_C_EVENT) ? true : false ;
36
+ };
37
+ SetConsoleCtrlHandler (
38
+ reinterpret_cast <PHANDLER_ROUTINE>(console_ctrl_handler), true );
39
+ #endif
31
40
auto config = file_manager_utils::GetCortexConfig ();
32
41
std::cout << " Host: " << config.apiServerHost
33
42
<< " Port: " << config.apiServerPort << " \n " ;
@@ -48,23 +57,8 @@ void RunServer() {
48
57
[&]() { asyncFileLogger.flush (); });
49
58
LOG_INFO << " Host: " << config.apiServerHost
50
59
<< " Port: " << config.apiServerPort << " \n " ;
51
- // Number of cortex.cpp threads
52
- // if (argc > 1) {
53
- // thread_num = std::atoi(argv[1]);
54
- // }
55
60
56
- // // Check for host argument
57
- // if (argc > 2) {
58
- // host = argv[2];
59
- // }
60
-
61
- // // Check for port argument
62
- // if (argc > 3) {
63
- // port = std::atoi(argv[3]); // Convert string argument to int
64
- // }
65
61
int thread_num = 1 ;
66
- // std::string host = "127.0.0.1";
67
- // int port = 3928;
68
62
69
63
int logical_cores = std::thread::hardware_concurrency ();
70
64
int drogon_thread_num = std::max (thread_num, logical_cores);
@@ -82,6 +76,7 @@ void RunServer() {
82
76
std::stoi (config.apiServerPort ));
83
77
drogon::app ().setThreadNum (drogon_thread_num);
84
78
LOG_INFO << " Number of thread is:" << drogon::app ().getThreadNum ();
79
+ drogon::app ().disableSigtermHandling ();
85
80
86
81
drogon::app ().run ();
87
82
// return 0;
@@ -161,4 +156,4 @@ int main(int argc, char* argv[]) {
161
156
CommandLineParser clp;
162
157
clp.SetupCommand (argc, argv);
163
158
return 0 ;
164
- }
159
+ }
0 commit comments