main.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <QCoreApplication>
  2. #include "ytservicecore.h"
  3. #include "core.h"
  4. #include "../../DataProcessService/ytUserInfoProcess/userinfo.h"
  5. YT_SERVICE_SHM *ytShm;
  6. WebDataShm *webData;
  7. SysConfShm *sysConfShm;
  8. UserInfoShm *userinfoShm;
  9. bool load_shm(){
  10. int shmid;
  11. key_t key;
  12. if((key = ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1)
  13. return false;
  14. if((shmid = shmget(key,sizeof(YT_SERVICE_SHM),IPC_CREAT|0666))==-1)
  15. return false;
  16. ytShm = static_cast<YT_SERVICE_SHM *>(shmat(shmid,nullptr,0));
  17. if((key = ftok(UISHM_PATH,static_cast<int>(UISHM_PORT)))==-1)
  18. return false;
  19. if((shmid = shmget(key,sizeof(UserInfoShm),IPC_CREAT|0666))==-1)
  20. return false;
  21. userinfoShm = static_cast<UserInfoShm *>(shmat(shmid,nullptr,0));
  22. if((key = ftok(WEB_SHM_PATH,static_cast<int>(WEB_SHM_PORT)))==-1)
  23. return false;
  24. if((shmid = shmget(key,sizeof(WebDataShm),IPC_CREAT|0666))==-1)
  25. return false;
  26. webData = static_cast<WebDataShm *>(shmat(shmid,nullptr,0));
  27. if((key = ftok(UISHM_PATH,static_cast<int>(SYSCONF_PORT)))==-1)
  28. return false;
  29. if((shmid = shmget(key,sizeof(SysConfShm),IPC_CREAT|0666))==-1)
  30. return false;
  31. sysConfShm = static_cast<SysConfShm *>(shmat(shmid,nullptr,0));
  32. return true;
  33. }
  34. int main(int argc, char *argv[])
  35. {
  36. QCoreApplication a(argc, argv);
  37. if(load_shm()){
  38. Core *c = new Core(nullptr);
  39. c->start();
  40. }
  41. return a.exec();
  42. }