Skip to content

Commit b038a90

Browse files
committed
added:support lua plugin file
1 parent 96278ad commit b038a90

File tree

2 files changed

+55
-17
lines changed

2 files changed

+55
-17
lines changed

XEngine_Source/XEngine_ServiceApp/XEngine_HttpApp/XEngine_Hdr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ extern XHANDLE xhHTTPPool;
9090
//配置文件
9191
extern XENGINE_SERVICECONFIG st_ServiceConfig;
9292
extern XENGINE_OPENCCCONFIG st_OPenccConfig;
93-
extern XENGINE_PLUGINCONFIG st_PluginConfig;
93+
extern XENGINE_PLUGINCONFIG st_PluginLibConfig;
94+
extern XENGINE_PLUGINCONFIG st_PluginLuaConfig;
9495
extern XENGINE_OPTIONLIST st_OPtionList;
9596
//连接库
9697
#ifdef _WINDOWS

XEngine_Source/XEngine_ServiceApp/XEngine_HttpApp/XEngine_HttpApp.cpp

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ XHANDLE xhHTTPPool = 0;
2020
//配置文件
2121
XENGINE_SERVICECONFIG st_ServiceConfig;
2222
XENGINE_OPENCCCONFIG st_OPenccConfig;
23-
XENGINE_PLUGINCONFIG st_PluginConfig;
23+
XENGINE_PLUGINCONFIG st_PluginLibConfig;
24+
XENGINE_PLUGINCONFIG st_PluginLuaConfig;
2425
XENGINE_OPTIONLIST st_OPtionList;
2526

2627
void ServiceApp_Stop(int signo)
@@ -41,7 +42,8 @@ void ServiceApp_Stop(int signo)
4142
ModuleDatabase_Bank_Destory();
4243
ModuleDatabase_ZIPCode_Destory();
4344
//销毁其他
44-
ModulePlugin_Core_Destroy();
45+
ModulePlugin_LibCore_Destroy();
46+
ModulePlugin_LuaCore_Destroy();
4547
ModuleHelp_P2PClient_Destory();
4648
//销毁日志资源
4749
HelpComponents_XLog_Destroy(xhLog);
@@ -98,7 +100,8 @@ int main(int argc, char** argv)
98100
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
99101
memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG));
100102
memset(&st_OPenccConfig, '\0', sizeof(XENGINE_OPENCCCONFIG));
101-
memset(&st_PluginConfig, '\0', sizeof(XENGINE_PLUGINCONFIG));
103+
memset(&st_PluginLibConfig, '\0', sizeof(XENGINE_PLUGINCONFIG));
104+
memset(&st_PluginLuaConfig, '\0', sizeof(XENGINE_PLUGINCONFIG));
102105

103106
st_XLogConfig.XLog_MaxBackupFile = 10;
104107
st_XLogConfig.XLog_MaxSize = 1024000;
@@ -139,12 +142,18 @@ int main(int argc, char** argv)
139142
//初始化插件配置
140143
if (st_ServiceConfig.st_XPlugin.bEnable)
141144
{
142-
if (!ModuleConfigure_Json_PluginFile(st_ServiceConfig.st_XPlugin.tszPluginFile, &st_PluginConfig))
145+
if (!ModuleConfigure_Json_PluginFile(st_ServiceConfig.st_XPlugin.tszPluginLib, &st_PluginLibConfig))
143146
{
144-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化插件配置文件失败,错误:%lX"), ModuleConfigure_GetLastError());
147+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Lib插件配置文件失败,错误:%lX"), ModuleConfigure_GetLastError());
145148
goto XENGINE_SERVICEAPP_EXIT;
146149
}
147-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化插件配置文件成功"));
150+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Lib插件配置文件成功"));
151+
if (!ModuleConfigure_Json_PluginFile(st_ServiceConfig.st_XPlugin.tszPluginLua, &st_PluginLuaConfig))
152+
{
153+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Lua插件配置文件失败,错误:%lX"), ModuleConfigure_GetLastError());
154+
goto XENGINE_SERVICEAPP_EXIT;
155+
}
156+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Lua插件配置文件成功"));
148157
}
149158
else
150159
{
@@ -249,31 +258,58 @@ int main(int argc, char** argv)
249258
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2P客户端管理器成功,超时时间设置:%d 秒"), st_ServiceConfig.st_XTime.nP2PTimeOut);
250259

251260
//启动插件
252-
if (!ModulePlugin_Core_Init())
261+
if (!ModulePlugin_LibCore_Init())
253262
{
254-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化插件系统失败,错误:%lX"), ModulePlugin_GetLastError());
263+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Lib插件系统失败,错误:%lX"), ModulePlugin_GetLastError());
255264
goto XENGINE_SERVICEAPP_EXIT;
256265
}
257266
//加载插件
258-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化插件系统成功,开始加载插件"));
267+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Lib插件系统成功,开始加载插件"));
268+
{
269+
list<XENGINE_PLUGININFO>::const_iterator stl_ListIterator = st_PluginLibConfig.pStl_ListPlugin->begin();
270+
for (int i = 1; stl_ListIterator != st_PluginLibConfig.pStl_ListPlugin->end(); stl_ListIterator++, i++)
271+
{
272+
if (stl_ListIterator->bEnable)
273+
{
274+
if (ModulePlugin_Loader_Insert(stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile, 0))
275+
{
276+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,加载Lib模块插件中,当前第:%d 个加载成功,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
277+
}
278+
else
279+
{
280+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,加载Lib模块插件中,当前第:%d 个加载失败,方法:%s,路径:%s,错误:%ld"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile, ModulePlugin_GetLastError());
281+
}
282+
}
283+
else
284+
{
285+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,加载Lib模块插件中,当前第:%d 个加载失败,因为没有启用,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
286+
}
287+
}
288+
}
289+
if (!ModulePlugin_LuaCore_Init())
290+
{
291+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化LUA插件系统失败,错误:%lX"), ModulePlugin_GetLastError());
292+
goto XENGINE_SERVICEAPP_EXIT;
293+
}
294+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化LUA插件系统成功,开始加载插件"));
259295
{
260-
list<XENGINE_PLUGININFO>::const_iterator stl_ListIterator = st_PluginConfig.pStl_ListPlugin->begin();
261-
for (int i = 1; stl_ListIterator != st_PluginConfig.pStl_ListPlugin->end(); stl_ListIterator++, i++)
296+
list<XENGINE_PLUGININFO>::const_iterator stl_ListIterator = st_PluginLuaConfig.pStl_ListPlugin->begin();
297+
for (int i = 1; stl_ListIterator != st_PluginLuaConfig.pStl_ListPlugin->end(); stl_ListIterator++, i++)
262298
{
263299
if (stl_ListIterator->bEnable)
264300
{
265-
if (ModulePlugin_Loader_Insert(stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile))
301+
if (ModulePlugin_Loader_Insert(stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile, 1))
266302
{
267-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,加载插件中,当前第:%d 个加载成功,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
303+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,加载LUA模块插件中,当前第:%d 个加载成功,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
268304
}
269305
else
270306
{
271-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,加载插件中,当前第:%d 个加载失败,方法:%s,路径:%s,错误:%ld"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile, ModulePlugin_GetLastError());
307+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,加载LUA模块插件中,当前第:%d 个加载失败,方法:%s,路径:%s,错误:%ld"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile, ModulePlugin_GetLastError());
272308
}
273309
}
274310
else
275311
{
276-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,加载插件中,当前第:%d 个加载失败,因为没有启用,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
312+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,加载LUA模块插件中,当前第:%d 个加载失败,因为没有启用,方法:%s,路径:%s"), i, stl_ListIterator->tszPluginMethod, stl_ListIterator->tszPluginFile);
277313
}
278314
}
279315
}
@@ -303,7 +339,8 @@ int main(int argc, char** argv)
303339
ModuleDatabase_Bank_Destory();
304340
ModuleDatabase_ZIPCode_Destory();
305341
//销毁其他
306-
ModulePlugin_Core_Destroy();
342+
ModulePlugin_LibCore_Destroy();
343+
ModulePlugin_LuaCore_Destroy();
307344
ModuleHelp_P2PClient_Destory();
308345
//销毁日志资源
309346
HelpComponents_XLog_Destroy(xhLog);

0 commit comments

Comments
 (0)