Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
loveyacper committed Sep 4, 2017
1 parent 4d9fc4e commit 313a631
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 23 deletions.
2 changes: 1 addition & 1 deletion LICENSE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You may add Your own copyright statement to Your modifications and may provide a

6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an ��AS IS�� BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
Expand Down
49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
### 该工程是Tars框架Nodejs语言的源代码 ###
[Click me switch to English version](README.en.md)

### 目录
# Tars

[config](config/README.md)
Tars这个名字取自于电影"星际穿越"中的机器人,它是基于名字服务使用Tars协议的高性能RPC开发框架,配套一体化的运营管理平台,并通过伸缩调度,实现运维半托管服务。

[deploy](deploy/README.md)
Tars是腾讯从2008年到今天一直在使用的后台逻辑层的统一应用框架TAF(Total Application Framework),目前支持C++和Java两种语言。该框架为用户提供了涉及到开发、运维、以及测试的一整套解决方案,帮助一个产品或者服务快速开发、部署、测试、上线。
它集可扩展协议编解码、高性能RPC通信框架、名字路由与发现、发布监控、日志统计、配置管理等于一体,通过它可以快速用微服务的方式构建自己的稳定可靠的分布式应用,并实现完整有效的服务治理。

[dyeing](dyeing/README.md)
目前该框架在腾讯内部,各大核心业务都在使用,颇受欢迎,基于该框架部署运行的服务节点规模达到上万个。

[logs](logs/README.md)
Tars详细介绍参见[Introduction.md](Introduction.md)

[monitor](monitor/README.md)
## 支持平台

[node-agent](node-agent/README.md)
目前运行的操作系统平台如下:

[notify](notify/README.md)
- Linux

[registry](registry/README.md)
## 支持语言

[rpc](rpc/README.md)
目前支持的开发语言如下:

[stream](stream/README.md)
- C++
- Java
- Nodejs

[utils](utils/README.md)
## 安装说明

[winston-tars](winston-tars/README.md)
初次安装时,请参考安装说明文档[Install.md](Install.md)

对安装比较熟后,可以参考[build](build)目录下的脚本进行安装(必要时需要修改)。

## 性能数据

参见[ docs/tars_performce.md](docs/tars_performce.md)

## 开发技术文档

参见[docs](docs)目录。

## License

Tars的开源协议为BSD-3-Clause,详情参见[LICENSE.TXT](LICENSE.TXT)

## 联系方式

qq技术交流群:579079160。

2 changes: 1 addition & 1 deletion cpp/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -Wall -Wno-deprecated")

#set(CMAKE_BUILD_TYPE "Debug")

set(TARS_VERSION "1.0.1")
set(TARS_VERSION "1.1.0")
add_definitions(-DTARS_VERSION="${TARS_VERSION}")

set(INSTALL_PREFIX "/usr/local/tars/cpp")
Expand Down
32 changes: 26 additions & 6 deletions cpp/framework/NodeServer/CommandPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ inline int CommandPatch::execute(string &sResult)
string sServerName = _patchRequest.groupname.empty()?_patchRequest.servername:_patchRequest.groupname;
string sLocalTgzPath = _localTgzBasePath + "/" + _patchRequest.appname + "." + sServerName;

string sShortFile = "";
string sRemoteTgzPath = "";
string sShortFile;
string sRemoteTgzPath;

if(_patchRequest.ostype != "")
{
Expand Down Expand Up @@ -411,7 +411,7 @@ inline int CommandPatch::execute(string &sResult)
*/
vector<string> files;
tars::TC_File::listDirectory(sLocalExtractPach, files, true);
if(files.size() == 0)
if(files.empty())
{
sResult = cmd + ",error!";
NODE_LOG("patchPro")->error() <<FILE_FUN<<sResult<< endl;
Expand All @@ -438,10 +438,30 @@ inline int CommandPatch::execute(string &sResult)
}
}

//对于taf_nodejs需要先删除exepath下的文件
if (iRet == 0)
{
if (_serverObjectPtr->getServerType() == "taf_nodejs")
{
if(TC_File::removeFile(_serverObjectPtr->getExePath(),true) != 0 || !TC_File::makeDirRecursive(_serverObjectPtr->getExePath()))
{
iRet = -8; //iRetCode = EM_ITEM_PERMISSION;
NODE_LOG("patchPro")->error() <<FILE_FUN<<"|deal path fail:"<<_serverObjectPtr->getExePath()<<"|"<<strerror(errno)<<endl;
}
}
}

if(iRet == 0)
{
//如果出错,这里会抛异常
TC_File::copyFile(sLocalExtractPach + "/" + sServerName, _serverObjectPtr->getExePath(), true);
if (_serverObjectPtr->getServerType() == "taf_nodejs")
{
TC_File::copyFile(sLocalExtractPach + "/" + sServerName+ "/" + sServerName, _serverObjectPtr->getExePath(), true);
}
else
{
//如果出错,这里会抛异常
TC_File::copyFile(sLocalExtractPach + "/" + sServerName, _serverObjectPtr->getExePath(), true);
}

//设置发布状态到主控
iRet = updatePatchResult(sResult);
Expand Down Expand Up @@ -472,7 +492,7 @@ inline int CommandPatch::execute(string &sResult)
}

//这里要求前端判断发布成功的必备条件是bSucc=true
_serverObjectPtr->setPatchResult(sResult, iRet==0?true:false);
_serverObjectPtr->setPatchResult(sResult, iRet == 0);

//设置发布结果,如果是发布异常了这里也设置,主要是设置进度为100%,方便前端判断
_serverObjectPtr->setPatched(true);
Expand Down
16 changes: 15 additions & 1 deletion cpp/framework/NodeServer/CommandStart.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ inline ServerCommand::ExeStatus CommandStart::canExecute(string& sResult)
return DIS_EXECUTABLE;
}

if (TC_File::isAbsolute(_exeFile) == true && !TC_File::isFileExistEx(_exeFile) && _serverObjectPtr->getStartScript().empty())
if (TC_File::isAbsolute(_exeFile) &&
!TC_File::isFileExistEx(_exeFile) &&
_serverObjectPtr->getStartScript().empty() &&
_serverObjectPtr->getServerType() != "tars_nodejs")
{
_serverObjectPtr->setPatched(false);
sResult = "The server exe patch " + _exeFile + " is not exist.";
Expand Down Expand Up @@ -257,7 +260,18 @@ inline bool CommandStart::startNormal(string& sResult)

osStartStcript << _exeFile << " " << TC_Common::tostr(vOptions) << endl;
}
else if (_serverObjectPtr->getServerType() == "tars_nodejs")
{
vOptions.push_back(sExePath + "/tars_nodejs/node-agent/bin/node-agent");
string s = sExePath + "/src/ -c " + sConfigFile;
vector<string> v = TC_Common::sepstr<string>(s," \t");
vOptions.insert(vOptions.end(), v.begin(), v.end());

//对于tars_nodejs类型需要修改下_exeFile
_exeFile = sExePath+"/tars_nodejs/node";

osStartStcript<<sExePath+"/tars_nodejs/node" <<" "<<TC_Common::tostr(vOptions)<<" &"<< endl;
}
else
{
//c++服务
Expand Down
8 changes: 8 additions & 0 deletions cpp/framework/RegistryServer/DbHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,15 @@ vector<ServerDescriptor> CDbHandle::getServers(const string& app, const string&
TC_Config tParent, tProfile;
tParent.parseString(mapProfile[res[i]["template_name"]]);
tProfile.parseString(server.profile);

int iDefaultAsyncThreadNum = 3;

if("taf_nodejs" == server.serverType)
{
//taf_nodejs类型的业务需要设置这个值为0
iDefaultAsyncThreadNum = 0;
}

int iConfigAsyncThreadNum = TC_Common::strto<int>(TC_Common::trim(res[i]["async_thread_num"]));
iDefaultAsyncThreadNum = iConfigAsyncThreadNum > iDefaultAsyncThreadNum ? iConfigAsyncThreadNum : iDefaultAsyncThreadNum;
server.asyncThreadNum = TC_Common::strto<int>(tProfile.get("/tars/application/client<asyncthread>", TC_Common::tostr(iDefaultAsyncThreadNum)));
Expand Down

0 comments on commit 313a631

Please sign in to comment.