Skip to content

Commit fe16975

Browse files
committed
modify:deamon process for service
1 parent 5b12997 commit fe16975

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

README.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ git submodule init
8787
git submodule update
8888

8989
#### Linux
90-
ubuntu:sudo apt install sudo apt install liblua5.4-dev libopencv-dev libopencv-contrib-dev libqrencode-dev libleptonica-dev libtesseract-dev
91-
centos:compile by self
92-
use makefile compile,UBUNTU24.04 x64 or RockyLinux 9 x64
90+
ubuntu:sudo apt install sudo apt install liblua5.4-dev libopencv-dev libopencv-contrib-dev libqrencode-dev libleptonica-dev libtesseract-dev -y
91+
centos:sudo dnf install lua-devel opencv-devel qrencode-devel leptonica-devel tesseract-devel -y
92+
use makefile compile,UBUNTU24.04 x64 or RockyLinux 9 x64
9393
Run it on the terminal
9494

9595
#### Macos

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ git clone https://gitee.com/xengine/XEngine_PhoneData.git XEngine_Source/XEngine
9494
直接运行即可
9595

9696
#### Linux
97-
ubuntu:sudo apt install liblua5.4-dev libopencv-dev libopencv-contrib-dev libqrencode-dev libleptonica-dev libtesseract-dev
98-
centos:需要自己编译
99-
Linux使用Makefile编译,UBUNTU24.04 x64或者RockyLinux 9 x64
97+
ubuntu:sudo apt install liblua5.4-dev libopencv-dev libopencv-contrib-dev libqrencode-dev libleptonica-dev libtesseract-dev -y
98+
centos:sudo dnf install lua-devel opencv-devel qrencode-devel leptonica-devel tesseract-devel -y
99+
Linux使用Makefile编译,UBUNTU24.04 x64或者RockyLinux 9 x64
100100
在控制台运行
101101

102102
#### Macos

XEngine_Source/XEngine_ServiceApp/XEngine_APIServiceApp/XEngine_APIServiceApp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*********************************************************************/
1313
bool bIsRun = false;
1414
XHANDLE xhLog = NULL;
15+
XLONG dwProcessID = 0;
1516
XENGINE_SERVICECONFIG st_ServiceConfig = {};
1617
// 服务名称,使用 constexpr 替代宏定义
1718
constexpr LPCTSTR XENGINE_SERVICE_NAME = _T("XEngine_APIService");
@@ -125,6 +126,11 @@ void WINAPI XEngine_ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
125126
bIsRun = true;
126127
while (bIsRun)
127128
{
129+
SYSTEMAPI_PROCESS_INFOMATION st_ProcessInfo = {};
130+
if (!SystemApi_Process_GetProcessInfo(&st_ProcessInfo, NULL, dwProcessID))
131+
{
132+
SystemApi_Process_CreateProcess(&dwProcessID, "./XEngine_HttpApp.exe", NULL, false);
133+
}
128134
Sleep(1000);
129135
}
130136
}
@@ -142,12 +148,14 @@ void WINAPI XEngine_ServiceCtrlHandler(DWORD dwControl)
142148
break;
143149
case SERVICE_CONTROL_STOP:
144150
bIsRun = false;
151+
SystemApi_Process_Stop(NULL, dwProcessID);
145152
st_ServiceStatus.dwCurrentState = SERVICE_STOPPED;
146153
SetServiceStatus(hServiceStatusHandle, &st_ServiceStatus);
147154
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("服务运行中,收到命令,停止运行"));
148155
break;
149156
case SERVICE_CONTROL_SHUTDOWN:
150157
bIsRun = false;
158+
SystemApi_Process_Stop(NULL, dwProcessID);
151159
st_ServiceStatus.dwCurrentState = SERVICE_STOPPED;
152160
SetServiceStatus(hServiceStatusHandle, &st_ServiceStatus);
153161
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("服务运行中,收到命令,关闭程序"));

XEngine_Source/XEngine_ServiceApp/XEngine_APIServiceApp/XEngine_CommHdr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ using namespace std;
1717
#include <XEngine_Include/XEngine_BaseLib/BaseSafe_Error.h>
1818
#include <XEngine_Include/XEngine_HelpComponents/XLog_Define.h>
1919
#include <XEngine_Include/XEngine_HelpComponents/XLog_Error.h>
20+
#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Define.h>
21+
#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Error.h>
2022
//加载模块头文件
2123
#include "../../XEngine_ModuleConfigure/ModuleConfig_Define.h"
2224
#include "../../XEngine_ModuleConfigure/ModuleConfig_Error.h"
@@ -42,6 +44,7 @@ extern XENGINE_SERVICECONFIG st_ServiceConfig;
4244
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
4345
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseSafe")
4446
#pragma comment(lib,"XEngine_HelpComponents/HelpComponents_XLog")
47+
#pragma comment(lib,"XEngine_SystemSdk/XEngine_SystemApi")
4548
#ifdef _DEBUG
4649
#ifdef _M_X64
4750
#pragma comment(lib,"../../x64/Debug/XEngine_ModuleConfigure.lib")

0 commit comments

Comments
 (0)