-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (38 loc) · 752 Bytes
/
main.cpp
File metadata and controls
46 lines (38 loc) · 752 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
39
40
41
42
43
44
45
46
#include "backend_manager.hpp"
#include "configuration.hpp"
#include "handler.hpp"
#include "init_listener.hpp"
#include "logger.hpp"
#include "sockaddr.hpp"
#include <sys/socket.h>
#include <utility> // std::move
int backlog = 100;
Log main_log ( "jserve.log" ,DEBUG);
int main() {
try {
read_config();
}
catch ( ... ) {
main_log << ERROR << "Failed to read config. Dying...";
}
try {
register_backend_plugins();
}
catch ( ... ) {
main_log << ERROR << "Failed to register backend plugins. Dying...";
exit ( 1 );
}
try {
Listener listener(backlog);
while (true) {
SocketAddress sa;
sa.address = NULL;
Socket s(listener.accept(sa));
spawn_handler(std::move(s));
}
}
catch (...)
{
exit(1);
}
}