89 lines
1.9 KiB
C++
89 lines
1.9 KiB
C++
//#include "https_sn.h"
|
|
#include "Config.h"
|
|
#include "TimeUtil.h"
|
|
#include "FileUtil.h"
|
|
#include "StringUtil.h"
|
|
#include "Utils.h"
|
|
#include "myqueue.h"
|
|
|
|
#include "EngineManager.h"
|
|
#include "AppCommon.h"
|
|
#include "ToWeb.h"
|
|
//using namespace ns_https_sn;
|
|
using namespace ai_matrix;
|
|
|
|
std::atomic_bool app_flag(true);
|
|
|
|
void SigHandler(int iSigno)
|
|
{
|
|
if (iSigno == SIGINT)
|
|
{
|
|
app_flag = false;
|
|
}
|
|
}
|
|
|
|
//定义配置文件地址
|
|
std::string strConfigYamlPath = "./config/config.yaml";
|
|
std::string strEngineYamlPath = "./config/matrix.yaml";
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
//加载配置文件
|
|
int iRetYaml = Config::GetIns()->readYaml(strConfigYamlPath);
|
|
if (-1 == iRetYaml)
|
|
{
|
|
LogError << "read yaml file error";
|
|
return -1;
|
|
}
|
|
|
|
ai_matrix::BaseConfig baseConfig = Config::GetIns()->getBaseConfig();
|
|
ai_matrix::LogConfig logConfig = Config::GetIns()->getLogConfig();
|
|
|
|
//设置日志信息
|
|
MatrixAiLog::Log::SetLogLevel(logConfig.strLevel);
|
|
MatrixAiLog::Log::SetLogFile(baseConfig.strLogPath);
|
|
|
|
if (!FileUtil::getins()->CreateDirPath("./logs"))
|
|
{
|
|
LogError << "日志目录创建失败";
|
|
return -1;
|
|
}
|
|
|
|
ToWeb::getins()->setConfig(Config::GetIns()->getHttpServerConfig());
|
|
|
|
//捕获信号
|
|
if (signal(SIGINT, SigHandler) == SIG_ERR)
|
|
{
|
|
LogError << "cannot catch SIGINT.";
|
|
return -1;
|
|
}
|
|
|
|
//acl初始化
|
|
EngineManager engineManager;
|
|
int ret = engineManager.Init();
|
|
if (ret != APP_ERR_OK)
|
|
{
|
|
LogError << "engineManager init error";
|
|
return -1;
|
|
}
|
|
ret = engineManager.load_yaml_config(strEngineYamlPath);
|
|
if (ret != APP_ERR_OK)
|
|
{
|
|
LogError << "load matrix.yaml error";
|
|
return -1;
|
|
}
|
|
|
|
engineManager.RunAllEngine();
|
|
|
|
while (app_flag)
|
|
{
|
|
usleep(1000);
|
|
}
|
|
//acl去初始化
|
|
engineManager.StopAllEngine();
|
|
engineManager.DeInit();
|
|
|
|
LogInfo << "app end";
|
|
return 0;
|
|
}
|