| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include <cstdio>
- #include "EslGateway.h"
- #include "Log.h"
- #include "Config.h"
- #include "WebSocketServer.h"
- #ifdef __linux__
- #include <sys/resource.h>
- #define CORE_SIZE 1024 * 1024 * 500
- #endif
- int dump()
- {
- struct rlimit crlmt;
- if (getrlimit(RLIMIT_CORE, &crlmt) == -1) {
- return -1;
- }
- LOG_INFO("Before set rlimit CORE dump current is:%d, max is:%d\n", (int)crlmt.rlim_cur, (int)crlmt.rlim_max);
- //crlmt.rlim_cur = (rlim_t)CORE_SIZE;
- //crlmt.rlim_max = (rlim_t)CORE_SIZE;
- // 设置新的资源限制
- crlmt.rlim_cur = RLIM_INFINITY; // 软限制为无限制
- crlmt.rlim_max = RLIM_INFINITY; // 硬限制为无限制
- if (setrlimit(RLIMIT_CORE, &crlmt) == -1) {
- return -1;
- }
- if (getrlimit(RLIMIT_CORE, &crlmt) == -1) {
- return -1;
- }
- LOG_INFO("After set rlimit CORE dump current is:%d, max is:%d\n", (int)crlmt.rlim_cur, (int)crlmt.rlim_max);
- return 0;
- }
- int main()
- {
- if (MYLog::instance()->Init("log4cpp.conf") != 0) {
- std::cout << "日志文件加载失败" << std::endl;
- getchar();
- return 0;
- }
- LOG_INFO("日志配置文件加载成功");
- if (!CConfig::GetInstance()->load()) {
- LOG_ERROR("FS配置文件加载失败");
- getchar();
- return 0;
- }
- LOG_INFO("FS配置文件加载成功");
- dump();
- std::unique_ptr<EslGateway> pEslGateway = std::make_unique<EslGateway>();
- if (!pEslGateway->initDB()) {
- getchar();
- return 0;
- }
- if (!pEslGateway->initWs()) {
- LOG_ERROR("websocket端口监听失败");
- getchar();
- return 0;
- }
- LOG_INFO("websocket监听成功");
- if (!pEslGateway->start()) {
- LOG_ERROR("FS链接失败");
- getchar();
- return 0;
- }
- LOG_INFO_S("FS链接成功");
- pEslGateway->runWs();
- return 0;
- }
|