Skip to content

Commit

Permalink
fix php/java/nodejs server start bug
Browse files Browse the repository at this point in the history
tarstat change to use shm
  • Loading branch information
315317396 committed Mar 31, 2020
1 parent 54830dd commit 5f0e831
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
16 changes: 6 additions & 10 deletions NodeServer/CommandLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,34 @@ inline int CommandLoad::execute(string& sResult)
_serverDir = TC_File::simplifyDirectory(_nodeInfo.dataDir + FILE_SEP + _desc.application + "." + _desc.serverName);
}

//获取服务框架配置文件
_confPath = _serverDir + FILE_SEP + "conf" + FILE_SEP;
_confFile = _confPath + _desc.application + "." + _desc.serverName + ".config.conf";
//若exePath不合法采用默认路径
//注意java服务启动方式特殊 可执行文件为java 须特殊处理
if (_exePath.empty())
{
_exePath = _serverDir + FILE_SEP + "bin" + FILE_SEP;
if (_serverType == "tars_java")
{
string sConfigFile = _serverObjectPtr->getConfigFile();

TC_Config conf;
conf.parseFile(sConfigFile);
conf.parseFile(_confFile);
_exeFile = conf.get("/tars/application/server<java>", "java");
}
else if (_serverType == "tars_node")
{
string sConfigFile = _serverObjectPtr->getConfigFile();

TC_Config conf;
conf.parseFile(sConfigFile);
conf.parseFile(_confFile);
_exeFile = conf.get("/tars/application/server<nodejs>", "node");
}
else if(_serverType == "tars_php")
{
string sConfigFile = _serverObjectPtr->getConfigFile();

TC_Config conf;
conf.parseFile(sConfigFile);
conf.parseFile(_confFile);
_exeFile = conf.get("/tars/application/server<php>", "php");
}
else
Expand Down Expand Up @@ -204,11 +205,6 @@ inline int CommandLoad::execute(string& sResult)
//创建配置lib文件目录
_libPath = _nodeInfo.dataDir + FILE_SEP + "lib" + FILE_SEP;

//获取服务框架配置文件
_confPath = _serverDir + FILE_SEP + "conf" + FILE_SEP;

_confFile = _confPath + _desc.application + "." + _desc.serverName + ".config.conf";

NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::execute"<< _serverType << ","
<< "exe_path=" << _exePath << ","
<< "exe_file=" << _exeFile << ","
Expand Down
12 changes: 6 additions & 6 deletions StatServer/StatHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
// #include <ext/pool_allocator.h>
using namespace tars;

typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,FileStorePolicy> HashMap;//FileStorePolicy
//typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,FileStorePolicy> HashMap;//FileStorePolicy

// #if TARGET_PLATFORM_IOS || TARGET_PLATFORM_WINDOWS
// typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,MemStorePolicy> HashMap;//FileStorePolicy
// #else
// typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,ShmStorePolicy> HashMap;//FileStorePolicy
// #endif
#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_WINDOWS
typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,MemStorePolicy> HashMap;//FileStorePolicy
#else
typedef TarsHashMap<StatMicMsgHead, StatMicMsgBody, ThreadLockPolicy,ShmStorePolicy> HashMap;//FileStorePolicy
#endif

#if TARGET_PLAFFORM_LINUX
#include <ext/pool_allocator.h>
Expand Down
22 changes: 11 additions & 11 deletions StatServer/StatServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ void StatServer::initHashMap()

_hashmap[i][k].initDataBlockSize(iMinBlock,iMaxBlock,iFactor);

if(TC_File::isFileExist(sHashMapFile))
{
iSize = TC_File::getFileSize(sHashMapFile);
}
// if(TC_File::isFileExist(sHashMapFile))
// {
// iSize = TC_File::getFileSize(sHashMapFile);
// }
// else
// {
// int fd = open(sHashMapFile.c_str(), O_CREAT|O_EXCL|O_RDWR, 0666);
Expand Down Expand Up @@ -270,21 +270,21 @@ void StatServer::initHashMap()


//_hashmap[i][k].initStore( sHashMapFile.c_str(), iSize );
// #if TARGET_PLATFORM_IOS || TARGET_PLATFORM_WINDOWS
// _hashmap[i][k].create(new char[iSize], iSize);
// #else
#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_WINDOWS
_hashmap[i][k].create(new char[iSize], iSize);
#else
// key_t key = ftok(sHashMapFile.c_str(), a[iChar%26]);

_hashmap[i][k].initStore( sHashMapFile.c_str(), iSize );
// _hashmap[i][k].initStore( sHashMapFile.c_str(), iSize );

// key_t key = tars::hash<string>()(sHashMapFile);
key_t key = tars::hash<string>()(sHashMapFile);

// // iChar++;

// TLOGDEBUG("init hash mem,shm key: 0x" << hex << key << dec << endl);

// _hashmap[i][k].initStore(key, iSize);
// #endif
_hashmap[i][k].initStore(key, iSize);
#endif
_hashmap[i][k].setAutoErase(false);

TLOGDEBUG("\n" << _hashmap[i][k].desc() << endl);
Expand Down
2 changes: 1 addition & 1 deletion tarscpp

0 comments on commit 5f0e831

Please sign in to comment.