#include #include "EslGateway.h" #include "Log.h" #include "Config.h" #include "WebSocketServer.h" #ifdef __linux__ #include #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 pEslGateway = std::make_unique(); 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; }