You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.1 KiB

1 year ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
  1. #include <signal.h>
  2. #include <sqlite3.h>
  3. #include "appbase/appbase.hpp"
  4. #include "appsetting/appsetting.hpp"
  5. #include "service/app_core.hpp"
  6. using namespace iflytop;
  7. using namespace core;
  8. using namespace std;
  9. namespace iflytop {
  10. using namespace iflytop;
  11. using namespace core;
  12. using namespace std;
  13. class Main {
  14. THISCLASS(Main);
  15. private:
  16. unique_ptr<Thread> thread;
  17. private:
  18. int main(int argc, char *argv[]);
  19. public:
  20. static Main *g_main;
  21. static void _onsignal(int signo) { g_main->onsignal(signo); }
  22. void onsignal(int signo);
  23. public:
  24. Main(/* args */) {}
  25. ~Main() {}
  26. void run(int argc, char *argv[]);
  27. void dosystem(string order, bool dump) {
  28. if (dump) logger->info("{}", order);
  29. system(order.c_str());
  30. }
  31. };
  32. }; // namespace iflytop
  33. /*******************************************************************************
  34. * MAIN => MAIN *
  35. *******************************************************************************/
  36. Main *Main::g_main;
  37. extern "C" {
  38. int main(int argc, char *argv[]) {
  39. Main main;
  40. Main::g_main = &main;
  41. main.run(argc, argv);
  42. }
  43. }
  44. namespace iflytop {}
  45. void Main::onsignal(int signo) { exit(0); }
  46. void Main::run(int argc, char *argv[]) {
  47. // ::signal(SIGINT, Main::_onsignal);
  48. thread.reset(new Thread("main", [&]() { exit(main(argc, argv)); }));
  49. while (true) sleep(1000);
  50. }
  51. int Main::main(int argc, char *argv[]) {
  52. /**
  53. * @brief
  54. */
  55. logger->info("system setup start.");
  56. spdlog::flush_on(spdlog::level::debug);
  57. logger->info("#");
  58. logger->info("# company:{}", "ifytop");
  59. logger->info("# version:{}", VERSION);
  60. logger->info("# project:{}", PROJECT_NAME);
  61. logger->info("#");
  62. logger->info("build {}.....", "Config");
  63. // 构造GConfig
  64. BUILD_AND_REG_SERRVICE(GConfig);
  65. GET_SERVICE(GConfig)->initialize();
  66. /**
  67. * @brief
  68. */
  69. // if (!device_id.empty()) GET_SERVICE(GConfig)->set_deviceId(device_id);
  70. auto config = GET_SERVICE(GConfig);
  71. // 构造MainControlService
  72. BUILD_AND_REG_SERRVICE(AppCore);
  73. logger->info("system setup end.");
  74. while (true) sleep(1000);
  75. }