main.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <QCoreApplication>
  2. #include <signal.h>
  3. #include "grpcclient.h"
  4. #include "ivversion.h"
  5. #include "ivexit.h"
  6. #include "ivbacktrace.h"
  7. static QCoreApplication * gApp;
  8. static grpcclient * gpgrpcclient;
  9. void ExitFunc()
  10. {
  11. // gApp->quit();
  12. delete gpgrpcclient;
  13. std::cout<<"driver_cloud_grpc_thread exit."<<std::endl;
  14. gApp->quit();
  15. }
  16. void signal_handler(int sig)
  17. {
  18. if(sig == SIGINT)
  19. {
  20. ExitFunc();
  21. }
  22. }
  23. int main(int argc, char *argv[])
  24. {
  25. showversion("driver_cloud_grpc_client");
  26. RegisterIVBackTrace();
  27. QCoreApplication a(argc, argv);
  28. gApp = &a;
  29. // std::thread * ptest = new std::thread(test);
  30. // return a.exec();
  31. char stryamlpath[256];
  32. if(argc<2)
  33. {
  34. snprintf(stryamlpath,255,"driver_cloud_grpc_thread.yaml");
  35. // strncpy(stryamlpath,abs_ymlpath,255);
  36. }
  37. else
  38. {
  39. strncpy(stryamlpath,argv[1],255);
  40. }
  41. // dec_yaml(stryamlpath);
  42. grpcclient * pgrpcclient = new grpcclient(stryamlpath);
  43. pgrpcclient->start();
  44. gpgrpcclient = pgrpcclient;
  45. signal(SIGINT,signal_handler);
  46. iv::ivexit::RegIVExitCall(ExitFunc);
  47. return a.exec();
  48. }