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.
73 lines
1.9 KiB
73 lines
1.9 KiB
#include "main.hpp"
|
|
|
|
#include <signal.h>
|
|
#include <sqlite3.h>
|
|
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
|
|
namespace iflytop {
|
|
bool g_preheat = false;
|
|
};
|
|
|
|
/*******************************************************************************
|
|
* MAIN => MAIN *
|
|
*******************************************************************************/
|
|
Main *Main::g_main;
|
|
int main(int argc, char *argv[]) {
|
|
Main main;
|
|
Main::g_main = &main;
|
|
main.run(argc, argv);
|
|
}
|
|
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 解析命令行参数
|
|
*/
|
|
string preheat;
|
|
auto cli = ((required("--preheat") & value("preheat", preheat)).doc("preheat"));
|
|
if (!parse(argc, argv, cli)) {
|
|
preheat = "true";
|
|
// cout << make_man_page(cli, argv[0]);
|
|
// exit(-1);
|
|
}
|
|
if (preheat == "false") {
|
|
g_preheat = false;
|
|
} else {
|
|
g_preheat = true;
|
|
}
|
|
logger->info("preheat:{}:{}", preheat, g_preheat);
|
|
|
|
/**
|
|
* @brief 系统初始化
|
|
*/
|
|
logger->info("system setup start.");
|
|
spdlog::flush_on(spdlog::level::debug);
|
|
logger->info("#");
|
|
logger->info("# company:{}", "ifytop");
|
|
logger->info("# version:{}", VERSION);
|
|
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);
|
|
}
|