main.cpp 516 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "pch/pch.h"
  2. #include "network/CServer.h"
  3. int main()
  4. {
  5. //初始化日志
  6. CLewaimaiLog log;
  7. log.Init();
  8. //读取配置文件
  9. CConfigReader::ReadConfigFile();
  10. //开启守护进程
  11. if (daemon(0, 0) == -1)
  12. {
  13. exit(EXIT_FAILURE);
  14. }
  15. try
  16. {
  17. //初始化服务器,开始监听和处理消息
  18. CServer s;
  19. s.Init();
  20. }
  21. catch (std::exception& e)
  22. {
  23. std::cerr << "Exception: " << e.what() << "\n";
  24. LOG_ERROR("Exception: " << e.what());
  25. }
  26. LOG_ERROR("ready to exit program");
  27. return 0;
  28. }