Skip to content

Commit 4903225

Browse files
committed
up
1 parent 20acca7 commit 4903225

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

kbe/src/lib/client_lib/kbemain.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,40 @@ inline void parseMainCommandArgs(int argc, char* argv[])
218218
}
219219
}
220220

221+
inline void setEvns()
222+
{
223+
std::string scomponentGroupOrder = "0";
224+
std::string scomponentGlobalOrder = "0";
225+
std::string scomponentID = "0";
226+
227+
if(g_componentGroupOrder > 0)
228+
{
229+
int32 icomponentGroupOrder = g_componentGroupOrder;
230+
scomponentGroupOrder = KBEngine::StringConv::val2str(icomponentGroupOrder);
231+
}
232+
233+
if(g_componentGlobalOrder > 0)
234+
{
235+
int32 icomponentGlobalOrder = g_componentGlobalOrder;
236+
scomponentGlobalOrder = KBEngine::StringConv::val2str(icomponentGlobalOrder);
237+
}
238+
239+
{
240+
uint64 v = g_componentID;
241+
scomponentID = KBEngine::StringConv::val2str(v);
242+
}
243+
244+
#if KBE_PLATFORM == PLATFORM_WIN32
245+
_putenv((std::string("KBE_COMPONENTID=") + scomponentID).c_str());
246+
_putenv((std::string("KBE_GLOBALID=") + scomponentGlobalOrder).c_str());
247+
_putenv((std::string("KBE_GROUPID=") + scomponentGroupOrder).c_str());
248+
#else
249+
setenv("KBE_COMPONENTID", scomponentID.c_str(), 1);
250+
setenv("KBE_GLOBALID", scomponentGlobalOrder.c_str(), 1);
251+
setenv("KBE_GROUPID", scomponentGroupOrder.c_str(), 1);
252+
#endif
253+
}
254+
221255
template <class CLIENT_APP>
222256
int kbeMainT(int argc, char * argv[], COMPONENT_TYPE componentType,
223257
int32 extlisteningPort_min = -1, int32 extlisteningPort_max = -1, const char * extlisteningInterface = "",
@@ -226,6 +260,7 @@ int kbeMainT(int argc, char * argv[], COMPONENT_TYPE componentType,
226260
g_componentID = genUUID64();
227261
g_componentType = componentType;
228262
parseMainCommandArgs(argc, argv);
263+
setEvns();
229264

230265
if(!loadConfig())
231266
{

0 commit comments

Comments
 (0)