|
1 | 1 | #include "MQService_Hdr.h" |
2 | 2 |
|
3 | | -bool bIsRun = false; |
| 3 | +bool bIsRun = true; |
| 4 | +bool bIsTest = false; |
4 | 5 | XHANDLE xhLog = NULL; |
5 | 6 | XHANDLE xhTCPSocket = NULL; |
6 | 7 | XHANDLE xhHTTPSocket = NULL; |
@@ -90,7 +91,6 @@ int main(int argc, char** argv) |
90 | 91 | WSADATA st_WSAData; |
91 | 92 | WSAStartup(MAKEWORD(2, 2), &st_WSAData); |
92 | 93 | #endif |
93 | | - bIsRun = true; |
94 | 94 | LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types"); |
95 | 95 | LPCXSTR lpszHTTPCode = _X("./XEngine_Config/HttpCode.types"); |
96 | 96 | LPCXSTR lpszDBConfig = _X("./XEngine_Config/XEngine_DBConfig.json"); |
@@ -354,40 +354,53 @@ int main(int argc, char** argv) |
354 | 354 |
|
355 | 355 | XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("所有服务成功启动,服务运行中,XEngine版本:%s%s,发行版本次数:%d,当前运行版本:%s。。。"), BaseLib_OperatorVer_XNumberStr(), BaseLib_OperatorVer_XTypeStr(), st_ServiceCfg.st_XVer.pStl_ListStorage->size(), st_ServiceCfg.st_XVer.pStl_ListStorage->front().c_str()); |
356 | 356 |
|
357 | | - while (true) |
| 357 | + bIsTest = true; |
| 358 | + while (bIsRun) |
358 | 359 | { |
| 360 | + if (bIsTest) |
| 361 | + { |
| 362 | + goto NETSERVICEEXIT; |
| 363 | + } |
359 | 364 | std::this_thread::sleep_for(std::chrono::seconds(1)); |
360 | 365 | } |
361 | 366 | NETSERVICEEXIT: |
362 | 367 |
|
363 | | - if (bIsRun) |
| 368 | + bIsRun = false; |
| 369 | + if (bIsTest) |
364 | 370 | { |
365 | | - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("有服务启动失败,服务器退出...")); |
366 | | - bIsRun = false; |
367 | | - |
368 | | - HelpComponents_Datas_Destory(xhTCPPacket); |
369 | | - HttpProtocol_Server_DestroyEx(xhHTTPPacket); |
370 | | - RfcComponents_WSPacket_DestoryEx(xhWSPacket); |
371 | | - MQTTProtocol_Parse_Destory(); |
372 | | - |
373 | | - NetCore_TCPXCore_DestroyEx(xhTCPSocket); |
374 | | - NetCore_TCPXCore_DestroyEx(xhHTTPSocket); |
375 | | - NetCore_TCPXCore_DestroyEx(xhWSSocket); |
376 | | - NetCore_TCPXCore_DestroyEx(xhMQTTSocket); |
377 | | - |
378 | | - ManagePool_Thread_NQDestroy(xhTCPPool); |
379 | | - ManagePool_Thread_NQDestroy(xhHttpPool); |
380 | | - ManagePool_Thread_NQDestroy(xhWSPool); |
381 | | - ManagePool_Thread_NQDestroy(xhMQTTPool); |
382 | | - |
383 | | - DBModule_MQData_Destory(); |
384 | | - DBModule_MQUser_Destory(); |
385 | | - |
386 | | - SessionModule_Client_Destory(); |
387 | | - HelpComponents_XLog_Destroy(xhLog); |
| 371 | + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("服务启动完毕,测试程序退出...")); |
| 372 | + } |
| 373 | + else |
| 374 | + { |
| 375 | + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("服务启动失败,服务器退出...")); |
388 | 376 | } |
| 377 | + HelpComponents_Datas_Destory(xhTCPPacket); |
| 378 | + HttpProtocol_Server_DestroyEx(xhHTTPPacket); |
| 379 | + RfcComponents_WSPacket_DestoryEx(xhWSPacket); |
| 380 | + MQTTProtocol_Parse_Destory(); |
| 381 | + |
| 382 | + NetCore_TCPXCore_DestroyEx(xhTCPSocket); |
| 383 | + NetCore_TCPXCore_DestroyEx(xhHTTPSocket); |
| 384 | + NetCore_TCPXCore_DestroyEx(xhWSSocket); |
| 385 | + NetCore_TCPXCore_DestroyEx(xhMQTTSocket); |
| 386 | + |
| 387 | + ManagePool_Thread_NQDestroy(xhTCPPool); |
| 388 | + ManagePool_Thread_NQDestroy(xhHttpPool); |
| 389 | + ManagePool_Thread_NQDestroy(xhWSPool); |
| 390 | + ManagePool_Thread_NQDestroy(xhMQTTPool); |
| 391 | + |
| 392 | + DBModule_MQData_Destory(); |
| 393 | + DBModule_MQUser_Destory(); |
| 394 | + |
| 395 | + SessionModule_Client_Destory(); |
| 396 | + HelpComponents_XLog_Destroy(xhLog); |
389 | 397 | #ifdef _WINDOWS |
390 | 398 | WSACleanup(); |
391 | 399 | #endif |
| 400 | + |
| 401 | + if (bIsTest) |
| 402 | + { |
| 403 | + return -1; |
| 404 | + } |
392 | 405 | return 0; |
393 | 406 | } |
0 commit comments