-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBeanMain.cpp
More file actions
50 lines (45 loc) · 1.55 KB
/
TestBeanMain.cpp
File metadata and controls
50 lines (45 loc) · 1.55 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <cstring>
#include "server/WebServer.hpp"
int main(int argc, char** argv) {
int option;
std::string configFileName;
if (argc > 2) {
std::cout << "[ERROR] invalid args count" << std::endl;
return 1;
}
if (argc == 1) {
std::cout << "[INFO] use default conf file ./config/default.conf"
<< std::endl;
configFileName = "server/config/default.conf";
option = 3;
} else {
configFileName = argv[1];
option = 3;
}
ConfigParser configParser;
configParser.parseConfig(configFileName);
std::map<std::pair<std::string, int>, ServerConfiguration*> serverConfigs;
std::map<std::pair<std::string, int>, Server>::iterator it =
configParser.server.begin();
while (it != configParser.server.end()) {
std::string serverName = it->first.first;
int port = it->first.second;
Server& server = it->second;
ServerConfiguration* serverConfig = new ServerConfiguration(server);
serverConfigs.insert(std::make_pair(
std::make_pair(server.getServerName(), server.getListen()),
serverConfig));
it++;
}
std::cout << "======================================\n";
Event* event;
event = 0; // Event 등록을 제외한 Test
ResponseConfig responseConfig; // response에서 사용하는 메서드 설정
ControllerMapping controllerMapping(serverConfigs); // Controller
WebServer& webServer = WebServer::getInstance(serverConfigs, option);
signal(SIGPIPE, SIG_IGN);
webServer.execute();
}