main.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <iostream>
  2. #include <signal.h>
  3. #include "UserApp.hpp"
  4. using namespace std;
  5. /**
  6. * @description: main
  7. * @param {int} argc
  8. * @param {char*} argv
  9. * @return {*}
  10. */
  11. int main(int argc, char* argv[]){
  12. static semaphore sem;
  13. signal(SIGINT, [](int) {
  14. sem.post();
  15. NoticeCenter::Instance().emitEvent(NOTICE_DESTROY);
  16. });// 设置退出信号
  17. //设置日志
  18. Logger::Instance().add(std::make_shared<ConsoleChannel>());
  19. #ifndef DEBUG
  20. Logger::Instance().add(std::make_shared<FileChannel>("FileChannel", "/home/GSD/log/birdy", LTrace));
  21. #else
  22. Logger::Instance().add(std::make_shared<FileChannel>());
  23. #endif
  24. Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
  25. gsd::UserApp::Ptr app = gsd::UserApp::CreateNew();
  26. if(app == nullptr){
  27. ErrorL << "APP Unable to create" << endl;
  28. return -1;
  29. }
  30. if(app->Init() == false){
  31. ErrorL << "Failed to start task" << endl;
  32. }
  33. // 启动任务
  34. app->StartTask();
  35. InfoL << "app Destroy" << endl;
  36. app->Destroy();
  37. return 0;
  38. }