-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (49 loc) · 1.73 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (49 loc) · 1.73 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
51
52
53
54
55
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.cpp :+: :+: */
/* +:+ */
/* By: bdekonin <bdekonin@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2022/08/19 16:16:08 by bdekonin #+# #+# */
/* Updated: 2022/11/08 22:39:46 by bdekonin ######## odam.nl */
/* */
/* ************************************************************************** */
#include <iostream>
#include <string.h>
#include <string>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
# include "inc/ServerConfiguration.hpp" // Derived from Configuration
# include "inc/Webserv.hpp"
# include "inc/Parser.hpp"
# include "inc/Server.hpp"
# include "inc/Job.hpp"
int main(int argc, char const *argv[])
{
if (argc != 2) {
std::cerr << "Usage: ./webserv <config_file>" << std::endl;
return EXIT_FAILURE;
}
(void)argc;
std::vector<ServerConfiguration> configs;
std::map<int, Server> servers; // port, server
Parser *parser = new Parser(argv[1]);
configs = parser->init();
delete parser;
Webserv server(configs);
server.setupServers();
try
{
server.run();
server.closeAll();
}
catch(const std::exception& e)
{
std::cerr << "catch: "<< e.what() << '\n';
server.closeAll();
}
return EXIT_SUCCESS;
}