forked from Pablichu/webserv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (33 loc) · 698 Bytes
/
main.cpp
File metadata and controls
37 lines (33 loc) · 698 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
#include "./includes/Server.hpp"
void leak_checker()
{
system("leaks webserv");
}
int main(int argc, char **argv)
{
Config config;
Server server;
if (argc == 1)
{
std::cout << " -> Default configuration" << std::endl;
config.setPath(".default/default.json");
}
else if (argc == 2)
config.setPath(argv[1]);
else
{
std::cout << "Need config file path as argument. Nothing else." << std::endl;
return (1);
}
if (!config.parseFile())
{
std::cout << "Invalid config file." << std::endl;
return (1);
}
if (!server.prepare(config.getConfig()))
return (1);
if (!server.start())
return (1);
//std::atexit(leak_checker);
return (0);
}