-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (29 loc) · 803 Bytes
/
main.cpp
File metadata and controls
34 lines (29 loc) · 803 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
#include <sys/socket.h>
#include <unistd.h>
#include <cstring>
#include <exception>
#include <iostream>
#include <sstream>
#include "Configuration.hpp"
#include "Connector.hpp"
int main(int argc, char* argv[]) {
Configuration& config = Configuration::getInstance();
std::string filename = "./conf/default.conf";
Connector connector;
try {
if (argc > 2) {
throw std::runtime_error("Usage: ./webserv <config_file>");
} else if (argc == 2) {
filename = argv[1];
}
config.initialize(filename);
connector.connectServerPorts();
connector.start();
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
delete &config;
return 1;
}
delete &config;
return 0;
}