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.

84 lines
2.3 KiB

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