Skip to content

Commit

Permalink
added:test start supported
Browse files Browse the repository at this point in the history
  • Loading branch information
xengine-qyt committed Sep 27, 2024
1 parent 87d061a commit 9fb8644
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ bool XEngine_Configure_Parament(int argc, char** argv)
{
st_ServiceConfig.bDebug = true;
}
else if (0 == _tcsxcmp("-t", argv[i]))
{
bIsTest = true;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ using namespace std;
// History:
*********************************************************************/
extern bool bIsRun;
extern bool bIsTest;
extern XHANDLE xhLog;
//HTTP服务器
extern XHANDLE xhHttpSocket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// History:
*********************************************************************/
bool bIsRun = false;
bool bIsTest = false;
XHANDLE xhLog = NULL;
//HTTP服务器
XHANDLE xhHttpSocket = NULL;
Expand Down Expand Up @@ -148,6 +149,7 @@ int main(int argc, char** argv)
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
#endif
bIsRun = true;
int nRet = 0;
LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types");
LPCXSTR lpszHTTPCode = _X("./XEngine_Config/HttpCode.types");
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
Expand Down Expand Up @@ -604,13 +606,26 @@ int main(int argc, char** argv)

while (true)
{
if (bIsTest)
{
nRet = 0;
break;
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}

XENGINE_SERVICEAPP_EXIT:
if (bIsRun)
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("有服务启动失败,服务器退出..."));
if (bIsTest && 0 == nRet)
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("服务启动完毕,测试程序退出..."));
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("有服务启动失败,服务器退出..."));
}

bIsRun = false;
//销毁网络
NetCore_TCPXCore_DestroyEx(xhHttpSocket);
Expand Down Expand Up @@ -665,5 +680,5 @@ int main(int argc, char** argv)
#ifdef _MSC_BUILD
WSACleanup();
#endif
return 0;
return nRet;
}

0 comments on commit 9fb8644

Please sign in to comment.