-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (36 loc) · 1.31 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (36 loc) · 1.31 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
#include "config.h"
int main(int argc, char* argv[]) {
// 需要修改的数据库信息,登录名,密码,库名
string mysql_host = "172.17.0.3";
int mysql_port = 3306;
string user = "root";
string passwd = "123456";
string databasename = "web_server";
// 命令行解析
Config config;
config.parse_arg(argc, argv);
WebServer server;
// 初始化
// actor_model: 0-Proactor模型 1-Reactor模型
// TRIGMode: (listen_fd, connfd)
// 0,表示使用 LT + LT m_LISTENTrigmode = 0, m_CONNTrigmode = 0
// 1,表示使用 LT + ET m_LISTENTrigmode = 0, m_CONNTrigmode = 1
// 2,表示使用 ET + LT m_LISTENTrigmode = 1, m_CONNTrigmode = 0
// 3,表示使用 ET + ET m_LISTENTrigmode = 1, m_CONNTrigmode = 1
server.init(config.PORT, mysql_host, mysql_port, user, passwd, databasename, config.LOGWrite,
config.OPT_LINGER, config.TRIGMode, config.sql_num, config.thread_num,
config.close_log, config.actor_model);
// 日志
server.log_write();
// 数据库
server.sql_pool();
// 线程池
server.thread_pool();
// 触发模式
server.trig_mode();
// 监听
server.eventListen();
// 运行
server.eventLoop();
return 0;
}