-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (36 loc) · 1.05 KB
/
main.cpp
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
#include <iostream>
#include <signal.h>
#include "include/config.h"
#include "include/Server.h"
#include "include/Client.h"
using std::endl;
using std::cout;
void signal_callback_handler(int);
Server* server;
int main()
{
signal(SIGINT, signal_callback_handler);
signal(SIGTERM, signal_callback_handler);
string location = config::get_sock_location();
string ip = config::get_host_ip();
int port = config::get_host_port();
if(!config::quiet_mode){
cout << "Starting WhiteBell server." << endl;
cout << "Server version: " << (int)Server::version << endl;
cout << "Protocol version: " << (int)Client::protocol_version << endl;
// cout << "Binding as unix stream: " << location << endl;
cout << "Binding as TCP: " << port << endl;
}
server = new Server(port);
server->run();
return 0;
}
void signal_callback_handler(int signum)
{
if(!config::quiet_mode){
cout << "Program interrupted with signal " << signum << endl;
}
server->stop();
delete server;
exit(0);
}