-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (42 loc) · 855 Bytes
/
Copy pathmain.cpp
File metadata and controls
52 lines (42 loc) · 855 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
47
48
49
50
51
52
/*
* Created on: Feb 20, 2013
* Author: ssobczak
*/
#include <stdlib.h>
#include <sstream>
#include <string>
#include <iostream>
#include <thread>
#include "args.h"
#include "config.h"
#include "dispatchserver.h"
#include "socketserver.h"
#include "workerspool.h"
int main(int argc, char* argv[]) {
Args args(argc, argv);
printf("Will load config from %s.\n", args.config.c_str());
Config cfg;
if (!cfg.read_config()) {
return EXIT_FAILURE;
}
WorkersPool wp(10);
DispatchServer server(wp);
if (!server.set_config(cfg)) {
return EXIT_FAILURE;
}
std::thread server_thread;
if (!server.spawn(&server_thread)) {
return EXIT_FAILURE;
}
std::string cmd;
while (std::cin >> cmd) {
if (cmd == "exit") {
if (!server.stop()) {
return EXIT_FAILURE;
}
break;
}
}
server_thread.join();
return EXIT_SUCCESS;
}