-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
38 lines (31 loc) · 795 Bytes
/
Copy pathtest.cpp
File metadata and controls
38 lines (31 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include"http_server.h"
#include<csignal>
#include<iostream>
std::atomic<bool> running{true};
void signalHandler(int sig){
if(sig == SIGINT || sig == SIGTERM){
std::cout << "\nShutting down server..." << std::endl;
running = false;
}
}
int main(int argc, char* argv[]){
int port = 8080;
int threads = 4;
if(argc > 1){
port = std::stoi(argv[1]);
}
if(argc > 2){
threads = std::stoi(argv[2]);
}
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
signal(SIGPIPE, SIG_IGN);
try{
HttpServer server(port, threads);
server.run();
}catch(const std::exception& e){
std::cerr << "Server error: " << e.what() << std::endl;
return 1;
}
return 0;
}