-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
55 lines (50 loc) · 1.73 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
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zel-bouz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/12 15:40:10 by zel-bouz #+# #+# */
/* Updated: 2024/03/18 22:05:03 by zel-bouz ### ########.fr */
/* */
/* ************************************************************************** */
#include "Parser/Parser.hpp"
// #include "Core/Server/Server.hpp"
#include "Core/CoreServer.hpp"
#include "Configuration/MainConf.hpp"
#include <signal.h>
void typingEffect( const std::string& message )
{
for (size_t i = 0; i < message.size(); i++) {
std::cout << message[i];
fflush(stdout);
usleep(10000);
}
std::cout << std::endl;
}
void handler( int sig )
{
(void)sig;
typingEffect("\b\b" + strTime() + " exiting server....");
delete CoreServer::getCore();
delete MainConf::getConf();
exit(0);
}
int main()
{
CoreServer *core = CoreServer::getCore();
signal(SIGINT, handler);
signal(SIGQUIT, handler);
signal(SIGPIPE, SIG_IGN);
try {
Parser parser;
parser.parse();
} catch (std::exception & e) {
std::cout << strTime() << " " << e.what() << std::endl;
}
core->init();
core->run();
delete CoreServer::getCore();
delete MainConf::getConf();
}