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.
90 lines
2.1 KiB
90 lines
2.1 KiB
|
|
#include <signal.h>
|
|
#include <sqlite3.h>
|
|
|
|
#include "appbase/dep.hpp"
|
|
#include "service/main_control_service.hpp"
|
|
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
|
|
namespace iflytop {
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
class Main {
|
|
THISCLASS(Main);
|
|
|
|
private:
|
|
unique_ptr<Thread> thread;
|
|
|
|
private:
|
|
int main(int argc, char *argv[]);
|
|
|
|
public:
|
|
static Main *g_main;
|
|
static void _onsignal(int signo) { g_main->onsignal(signo); }
|
|
void onsignal(int signo);
|
|
|
|
public:
|
|
Main(/* args */) {}
|
|
~Main() {}
|
|
void run(int argc, char *argv[]);
|
|
void dosystem(string order, bool dump) {
|
|
if (dump) logger->info("{}", order);
|
|
system(order.c_str());
|
|
}
|
|
};
|
|
|
|
}; // namespace iflytop
|
|
|
|
/*******************************************************************************
|
|
* MAIN => MAIN *
|
|
*******************************************************************************/
|
|
Main *Main::g_main;
|
|
extern "C" {
|
|
int main(int argc, char *argv[]) {
|
|
Main main;
|
|
Main::g_main = &main;
|
|
main.run(argc, argv);
|
|
}
|
|
}
|
|
namespace iflytop {
|
|
}
|
|
void Main::onsignal(int signo) { exit(0); }
|
|
void Main::run(int argc, char *argv[]) {
|
|
// ::signal(SIGINT, Main::_onsignal);
|
|
thread.reset(new Thread("main", [&]() { exit(main(argc, argv)); }));
|
|
while (true) sleep(1000);
|
|
}
|
|
int Main::main(int argc, char *argv[]) {
|
|
|
|
/**
|
|
* @brief 系统初始化
|
|
*/
|
|
logger->info("system setup start.");
|
|
spdlog::flush_on(spdlog::level::debug);
|
|
logger->info("#");
|
|
logger->info("# company:{}", "ifytop");
|
|
logger->info("# version:{}", VERSION);
|
|
logger->info("# project:{}", PROJECT_NAME);
|
|
logger->info("#");
|
|
logger->info("build {}.....", "Config");
|
|
// 构造GConfig
|
|
BUILD_AND_REG_SERRVICE(GConfig);
|
|
GET_SERVICE(GConfig)->initialize();
|
|
|
|
/**
|
|
* @brief
|
|
*/
|
|
// if (!device_id.empty()) GET_SERVICE(GConfig)->set_deviceId(device_id);
|
|
|
|
auto config = GET_SERVICE(GConfig);
|
|
|
|
// 构造MainControlService
|
|
BUILD_AND_REG_SERRVICE(MainControlService);
|
|
GET_SERVICE(MainControlService)->initialize();
|
|
logger->info("system setup end.");
|
|
while (true) sleep(1000);
|
|
}
|