12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <QCoreApplication>
- #include <signal.h>
- #include "grpcclient.h"
- #include "ivversion.h"
- #include "ivexit.h"
- #include "ivbacktrace.h"
- static QCoreApplication * gApp;
- static grpcclient * gpgrpcclient;
- void ExitFunc()
- {
- // gApp->quit();
- delete gpgrpcclient;
- std::cout<<"driver_cloud_grpc_thread exit."<<std::endl;
- gApp->quit();
- }
- void signal_handler(int sig)
- {
- if(sig == SIGINT)
- {
- ExitFunc();
- }
- }
- int main(int argc, char *argv[])
- {
- showversion("driver_cloud_grpc_client");
- RegisterIVBackTrace();
- QCoreApplication a(argc, argv);
- gApp = &a;
- // std::thread * ptest = new std::thread(test);
- // return a.exec();
- char stryamlpath[256];
- if(argc<2)
- {
- snprintf(stryamlpath,255,"driver_cloud_grpc_thread.yaml");
- // strncpy(stryamlpath,abs_ymlpath,255);
- }
- else
- {
- strncpy(stryamlpath,argv[1],255);
- }
- // dec_yaml(stryamlpath);
- grpcclient * pgrpcclient = new grpcclient(stryamlpath);
- pgrpcclient->start();
- gpgrpcclient = pgrpcclient;
- signal(SIGINT,signal_handler);
- iv::ivexit::RegIVExitCall(ExitFunc);
- return a.exec();
- }
|