#include <iostream>
#include <signal.h>

#include "ins_Packet.hpp"
#include "UserApp.hpp"

using namespace std;
using namespace toolkit;
using namespace ins;

int main(int argc, char *argv[])
{
    //设置退出信号处理函数
    static semaphore sem;
    signal(SIGINT, [](int) { sem.post(); });// 设置退出信号

    // 设置日志
    Logger::Instance().add(std::make_shared<ConsoleChannel>());
    //Logger::Instance().add(std::make_shared<FileChannel>());
    Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());

    std::string appName = "ins";

    userApp::Ptr app = userApp::CreateNew();

    if(app->Init(appName) != OK){
        ErrorL << "app 初始化失败" << endl;
        return -1;
    }
    if(app->StartTask() != OK) {
        ErrorL << "app 启动任务失败" << endl;
        return -1;
    }
    //sem.wait(); // describe
    return 0;
}
