Skip to content

Commit f0c89e5

Browse files
committed
fix tarsnode use old config for tars framework server
1 parent 898c371 commit f0c89e5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

NodeServer/CommandLoad.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ ServerCommand::ExeStatus CommandLoad::canExecute(string& sResult)
2626
{
2727
TC_ThreadRecLock::Lock lock(*_serverObjectPtr);
2828

29-
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute " << _desc.application << "." << _desc.serverName << "|" << _desc.setId << "| beging loaded------|" << endl;
29+
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute " << _desc.application << "." << _desc.serverName << "|" << _desc.setId << "| beging loaded------|" << endl;
3030

3131
ServerObject::InternalServerState eState = _serverObjectPtr->getInternalState();
3232

3333
if (_desc.application == "" || _desc.serverName == "")
3434
{
35-
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute app or server name is empty"<< endl;
35+
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute app or server name is empty"<< endl;
3636
return DIS_EXECUTABLE;
3737
}
3838

3939
if (_serverObjectPtr->toStringState(eState).find("ing") != string::npos && eState != ServerObject::Activating)
4040
{
41-
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute cannot loading the config, the server state is "<<_serverObjectPtr->toStringState(eState)<< endl;
41+
NODE_LOG("KeepAliveThread")->debug() << "CommandLoad::canExecute cannot loading the config, the server state is "<<_serverObjectPtr->toStringState(eState)<< endl;
4242
return DIS_EXECUTABLE;
4343
}
4444

@@ -70,10 +70,13 @@ int CommandLoad::execute(string& sResult)
7070

7171
if(_desc.application == "tars") {
7272
//tars服务特殊处理, 第一次用安装时的配置文件覆盖tarsnode data目录下服务的配置, 保证local端口不变化!
73-
string oldConf = TC_File::simplifyDirectory(_nodeInfo.dataDir + FILE_SEP + ".." + FILE_SEP + ".." + _desc.application + FILE_SEP + "conf" + FILE_SEP + _desc.application + "." + _desc.serverName + ".config.conf";
73+
string oldConf = TC_File::simplifyDirectory(_nodeInfo.dataDir + FILE_SEP + ".." + FILE_SEP + ".." + FILE_SEP + _desc.serverName + FILE_SEP + "conf" + FILE_SEP + _desc.application + "." + _desc.serverName + ".config.conf");
7474

75-
if(!TC_File::isFileExists(_confFile) && TC_File::isFileExists(oldConf)) {
76-
TC_File::copy(oldConf, _confFile);
75+
NODE_LOG("KeepAliveThread")->debug() << "oldConf:" << oldConf << ", confFile:" << _confFile << endl;
76+
77+
if(!TC_File::isFileExist(_confFile) && TC_File::isFileExist(oldConf)) {
78+
TC_File::makeDirRecursive(_confPath);
79+
TC_File::copyFile(oldConf, _confFile);
7780
}
7881

7982
}

0 commit comments

Comments
 (0)