-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.cpp
87 lines (76 loc) · 1.81 KB
/
config.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "config.h"
Config::Config(){
//端口号,默认8000 -p
PORT = 8000;
//日志写入方式,默认同步 -l
LOGWrite = 0;
//触发组合模式,默认listenfd LT + connfd LT -m
TRIGMode = 0;
//listenfd触发模式,默认LT
LISTENTrigmode = 0;
//connfd触发模式,默认LT
CONNTrigmode = 0;
//优雅关闭链接,默认不使用
OPT_LINGER = 0;
//数据库连接池数量,默认8
sql_num = 8;
//线程池内的线程数量,默认8
thread_num = 8;
//关闭日志,默认不关闭
close_log = 0;
//并发模型,默认是proactor
actor_model = 0;
}
void Config::parse_arg(int argc, char*argv[]){
int opt;
const char *str = "p:l:o:s:t:c:";
//const char* str = "p:l:m:o:s:t:c:a:";
while ((opt = getopt(argc, argv, str)) != -1)
{
switch (opt)
{
case 'p'://端口号
{
PORT = atoi(optarg);
break;
}
case 'l'://日志写入方式同步 异步
{
LOGWrite = atoi(optarg);
break;
}
case 'm':
{
TRIGMode = atoi(optarg);
break;
}
case 'o'://是否启用优雅关闭链接
{
OPT_LINGER = atoi(optarg);
break;
}
case 's'://数据库连接池连接个数
{
sql_num = atoi(optarg);
break;
}
case 't'://线程池线程个数
{
thread_num = atoi(optarg);
break;
}
case 'c'://是否关闭日志 默认不关闭
{
close_log = atoi(optarg);
break;
}
case 'a':
{
actor_model = atoi(optarg);
break;
}
default:
break;
}
}
}