2019-07-27 22:44:32 +08:00
|
|
|
|
#include "stdafx.h"
|
2015-07-05 01:29:35 +08:00
|
|
|
|
#include "master_service.h"
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 初始化 acl 库
|
2015-07-05 01:29:35 +08:00
|
|
|
|
acl::acl_cpp_init();
|
|
|
|
|
|
|
|
|
|
master_service& ms = acl::singleton2<master_service>::get_instance();
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 设置配置参数表
|
2015-07-05 01:29:35 +08:00
|
|
|
|
ms.set_cfg_int(var_conf_int_tab);
|
|
|
|
|
ms.set_cfg_int64(var_conf_int64_tab);
|
|
|
|
|
ms.set_cfg_str(var_conf_str_tab);
|
|
|
|
|
ms.set_cfg_bool(var_conf_bool_tab);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 开始运行
|
2015-07-05 01:29:35 +08:00
|
|
|
|
|
|
|
|
|
if (argc >= 2 && strcmp(argv[1], "alone") == 0)
|
|
|
|
|
{
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 日志输出至标准输出
|
2015-07-05 01:29:35 +08:00
|
|
|
|
acl::log::stdout_open(true);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 监听的地址列表,格式:ip:port1,ip:port2,...
|
2015-08-14 17:28:30 +08:00
|
|
|
|
const char* addrs = ":8888";
|
2015-07-05 01:29:35 +08:00
|
|
|
|
printf("listen on: %s\r\n", addrs);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 测试时设置该值 > 0 则指定服务器处理客户端连接过程的
|
|
|
|
|
// 会话总数(一个连接从接收到关闭称之为一个会话),当
|
|
|
|
|
// 处理的连接会话数超过此值,测试过程结束;如果该值设
|
|
|
|
|
// 为 0,则测试过程永远不结束
|
2015-07-05 01:29:35 +08:00
|
|
|
|
unsigned int count = 0;
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 测试过程中指定线程池最大线程个数
|
2015-07-05 01:29:35 +08:00
|
|
|
|
unsigned int max_threads = 100;
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 单独运行方式
|
2015-07-05 01:29:35 +08:00
|
|
|
|
|
|
|
|
|
if (argc >= 3)
|
|
|
|
|
ms.run_alone(addrs, argv[2], count, max_threads);
|
|
|
|
|
else
|
|
|
|
|
ms.run_alone(addrs, NULL, count, max_threads);
|
|
|
|
|
|
|
|
|
|
printf("Enter any key to exit now\r\n");
|
|
|
|
|
getchar();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 日志输出至标准输出
|
2015-07-05 01:29:35 +08:00
|
|
|
|
acl::log::stdout_open(true);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 监听的地址列表,格式:ip:port1,ip:port2,...
|
2015-07-05 22:51:31 +08:00
|
|
|
|
const char* addrs = ":8888";
|
2015-07-05 01:29:35 +08:00
|
|
|
|
printf("listen on: %s\r\n", addrs);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 测试时设置该值 > 0 则指定服务器处理客户端连接过程的
|
|
|
|
|
// 会话总数(一个连接从接收到关闭称之为一个会话),当
|
|
|
|
|
// 处理的连接会话数超过此值,测试过程结束;如果该值设
|
|
|
|
|
// 为 0,则测试过程永远不结束
|
2015-07-05 01:29:35 +08:00
|
|
|
|
unsigned int count = 0;
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 测试过程中指定线程池最大线程个数
|
2015-07-05 01:29:35 +08:00
|
|
|
|
unsigned int max_threads = 100;
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 单独运行方式
|
2015-07-05 01:29:35 +08:00
|
|
|
|
ms.run_alone(addrs, NULL, count, max_threads);
|
|
|
|
|
printf("Enter any key to exit now\r\n");
|
|
|
|
|
getchar();
|
|
|
|
|
#else
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// acl_master 控制模式运行
|
2015-07-05 01:29:35 +08:00
|
|
|
|
ms.run_daemon(argc, argv);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|