Skip to content

Commit

Permalink
Merge branch 'release/2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Jun 2, 2020
2 parents a9be4a7 + 325d6aa commit 1b650ec
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 54 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: deploy-docker

on:
push:
tags:
- v*
jobs:
build:
runs-on: self-hosted
steps:
- name: docker login
run: |
docker login -u ${{ secrets.name }} -p ${{ secrets.pass }}
- name: deploy docker
run: |
echo $GITHUB_SHA
tag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always)
echo $tag
git clone https://github.com/TarsCloud/TarsDocker
cd TarsDocker/framework
./build-docker.sh $tag
40 changes: 40 additions & 0 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: test-pull-request

on:
pull_request:
branches:
- release/*
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v1
- name: init submodules
run: |
git submodule init tarscpp
git submodule update
cd tarscpp
git submodule init unittest servant/protocol
git submodule update
cd ..
- name: test framework
run: |
echo "Pull request's base branch is: ${{ github.base_ref }}"
BASE_BRANCH=${{ github.base_ref }}
echo $GITHUB_SHA
echo $GITHUB_REF
echo $BASE_BRANCH > /tmp/$GITHUB_SHA
release=$(sed "s/release\///g" /tmp/$GITHUB_SHA)
cp test/Dockerfile ../
cd ..
rm -rf TarsWeb
git clone --branch $BASE_BRANCH https://github.com/TarsCloud/TarsWeb
cd TarsWeb
webLatestTag=$(git describe --tags `git rev-list --tags --max-count=1` --abbrev=0 --always)
git checkout $webLatestTag
cd ..
docker build . --file Dockerfile --tag tarscloud/framework:$release
rm -rf TarsDemo
git clone https://github.com/TarsCloud/TarsDemo
cd TarsDemo
./autorun.sh $release latest false false
21 changes: 21 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test-release

on:
push:
branches:
- release/*
jobs:
build:
runs-on: self-hosted
steps:
- name: test release
run: |
echo $GITHUB_SHA
echo $GITHUB_REF
echo $GITHUB_REF > /tmp/$GITHUB_SHA
release=$(sed "s/refs\/heads\/release\///g" /tmp/$GITHUB_SHA)
echo $release
rm -rf TarsDocker
git clone https://github.com/TarsCloud/TarsDocker
cd TarsDocker/framework
./test-release.sh $release
5 changes: 4 additions & 1 deletion Changelist.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
1 fix registry db protect bug
2 deploy support centos 6
3 when mysql is not alive, Cycle detection
3 deploy tars, when mysql is not alive, Cycle detection
4 registry default close day log
### cn:
1 修复registry db protect的功能
2 部署支持centos 6
3 部署时, mysql如果不连通, 循环检测
4 registry默认关闭按天日志

## v2.4.0 2020.05.06
### en:
Expand Down Expand Up @@ -119,4 +122,4 @@ file

## v2.0.1 2020.03.03
- support mac & linux
- depends tarscpp v2.0.0
- depends tarscpp v2.0.0
2 changes: 1 addition & 1 deletion NotifyServer/LoadDbThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void LoadDbThread::init()
void LoadDbThread::run()
{
size_t iLastTime = 0;
size_t iNow = TNOW;

while (!_terminate)
{
size_t iNow = TNOW;
if(iNow - iLastTime >= _interval)
{
iLastTime = iNow;
Expand Down
84 changes: 41 additions & 43 deletions RegistryServer/QueryImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void QueryImp::initialize()
//初始化配置db连接
_db.init(g_pconf);

_openDayLog = g_pconf->get("/tars/reap<openDayLog>", "N") == "Y";
}

vector<EndpointF> QueryImp::findObjectById(const string & id, tars::TarsCurrentPtr current)
Expand Down Expand Up @@ -119,49 +120,46 @@ Int32 QueryImp::findObjectByIdInSameSet(const std::string & id,const std::string

void QueryImp::doDaylog(const FUNID eFnId,const string& id,const vector<tars::EndpointF> &activeEp, const vector<tars::EndpointF> &inactiveEp, const tars::TarsCurrentPtr& current,const ostringstream& os,const string& sSetid)
{
string sEpList;
for(size_t i = 0; i < activeEp.size(); i++)
{
if(0 != i)
{
sEpList += ";";
}
sEpList += activeEp[i].host + ":" + TC_Common::tostr(activeEp[i].port);
}

sEpList += "|";

for(size_t i = 0; i < inactiveEp.size(); i++)
{
if(0 != i)
{
sEpList += ";";
}
sEpList += inactiveEp[i].host + ":" + TC_Common::tostr(inactiveEp[i].port);
}

switch(eFnId)
{
case FUNID_findObjectById4All:
case FUNID_findObjectByIdInSameGroup:
{
FDLOG("query_idc") << eFunTostr(eFnId)<<"|"<<current->getHostName() << "|"<< current->getPort() << "|" << id << "|" <<sSetid << "|" << sEpList <<os.str()<< endl;
}
break;
case FUNID_findObjectByIdInSameSet:
{
FDLOG("query_set") << eFunTostr(eFnId)<<"|"<<current->getHostName() << "|"<< current->getPort() << "|" << id << "|" <<sSetid << "|" << sEpList <<os.str()<< endl;
}
break;
case FUNID_findObjectById4Any:
case FUNID_findObjectById:
case FUNID_findObjectByIdInSameStation:
default:
{
FDLOG("query") << eFunTostr(eFnId)<<"|"<<current->getHostName() << "|"<< current->getPort() << "|" << id << "|" <<sSetid << "|" << sEpList <<os.str()<< endl;
}
break;
}
if(_openDayLog) {
string sEpList;
for (size_t i = 0; i < activeEp.size(); i++) {
if (0 != i) {
sEpList += ";";
}
sEpList += activeEp[i].host + ":" + TC_Common::tostr(activeEp[i].port);
}

sEpList += "|";

for (size_t i = 0; i < inactiveEp.size(); i++) {
if (0 != i) {
sEpList += ";";
}
sEpList += inactiveEp[i].host + ":" + TC_Common::tostr(inactiveEp[i].port);
}

switch (eFnId) {
case FUNID_findObjectById4All:
case FUNID_findObjectByIdInSameGroup: {
FDLOG("query_idc") << eFunTostr(eFnId) << "|" << current->getHostName() << "|" << current->getPort()
<< "|" << id << "|" << sSetid << "|" << sEpList << os.str() << endl;
}
break;
case FUNID_findObjectByIdInSameSet: {
FDLOG("query_set") << eFunTostr(eFnId) << "|" << current->getHostName() << "|" << current->getPort()
<< "|" << id << "|" << sSetid << "|" << sEpList << os.str() << endl;
}
break;
case FUNID_findObjectById4Any:
case FUNID_findObjectById:
case FUNID_findObjectByIdInSameStation:
default: {
FDLOG("query") << eFunTostr(eFnId) << "|" << current->getHostName() << "|" << current->getPort() << "|"
<< id << "|" << sSetid << "|" << sEpList << os.str() << endl;
}
break;
}
}
}

string QueryImp::eFunTostr(const FUNID eFnId)
Expand Down
2 changes: 2 additions & 0 deletions RegistryServer/QueryImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class QueryImp: public QueryF
//数据库操作
CDbHandle _db;

bool _openDayLog = false;

};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
# heartbeatoff=Y

asyncthread = 6

#open day log, default is N; Y means open day log
openDayLog = N
</reap>
<objname>
#patch对象
Expand Down
4 changes: 4 additions & 0 deletions deploy/framework/sql/template/tars.tarsregistry
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
# heartbeatoff=Y

asyncthread = 6

#open day log, default is N; Y means open day log
openDayLog = N

</reap>
<objname>
#patch对象
Expand Down
24 changes: 15 additions & 9 deletions deploy/linux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,21 @@ OS=`uname`
if [[ "$OS" =~ "Darwin" ]]; then
OS=3
else
OS=`cat /etc/os-release`
if [[ "$OS" =~ "CentOS" ]] || [[ "$OS" =~ "Tencent tlinux" ]]; then
OS=`cat /etc/redhat-release`
if [[ "$OS" =~ "CentOS release 6" ]]; then
OS=1
elif [[ "$OS" =~ "Ubuntu" ]]; then
OS=2
NODE_VERSION="v10.20.1"
else
echo "OS not support:"
echo $OS
exit 1
OS=`cat /etc/os-release`
if [[ "$OS" =~ "CentOS" ]] || [[ "$OS" =~ "Tencent tlinux" ]]; then
OS=1
elif [[ "$OS" =~ "Ubuntu" ]]; then
OS=2
else
echo "OS not support:"
echo $OS
exit 1
fi
fi
fi

Expand All @@ -73,7 +79,7 @@ function exec_profile()
function get_host_ip()
{
if [ $OS == 1 ]; then
IP=`ifconfig | grep $1 -A3 | grep inet | grep broad | awk '{print $2}'`
IP=`ifconfig | grep $1 -A 1 | tail -1 | awk '{print $2}' | cut -d ':' -f 2`
elif [ $OS == 2 ]; then
IP=`ifconfig | sed 's/addr//g' | grep $1 -A3 | grep "inet " | awk -F'[ :]+' '{print $3}'`
elif [ $OS == 3 ]; then
Expand Down Expand Up @@ -147,7 +153,7 @@ if [ "${SLAVE}" != "true" ]; then
rm -rf v0.35.1.zip
#centos8 need chmod a+x
chmod a+x /usr/bin/unzip
wget https://github.com/nvm-sh/nvm/archive/v0.35.1.zip;/usr/bin/unzip v0.35.1.zip
wget https://github.com/nvm-sh/nvm/archive/v0.35.1.zip --no-check-certificate;/usr/bin/unzip v0.35.1.zip

NVM_HOME=$HOME

Expand Down
53 changes: 53 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# pull source and build docker auto in docker hub
FROM centos/systemd

WORKDIR /root/

ENV TARS_INSTALL /usr/local/tars/cpp/deploy

COPY "./TarsFramework" /tmp/Tars/framework
COPY "./TarsWeb" /tmp/Tars/web

# RUN rpm -ivh https://repo.mysql.com/mysql57-community-release-el7.rpm
RUN yum makecache fast \
&& yum install -y yum-utils psmisc file which net-tools wget unzip telnet git gcc gcc-c++ make glibc-devel flex bison ncurses-devel protobuf-devel zlib-devel openssl-devel \
# Install cmake
&& mkdir -p /tmp/cmake/ \
&& cd /tmp/cmake \
&& wget https://tars-thirdpart-1300910346.cos.ap-guangzhou.myqcloud.com/src/cmake-3.16.4.tar.gz \
&& tar xzf cmake-3.16.4.tar.gz \
&& cd cmake-3.16.4 \
&& ./configure \
&& make && make install \
# Install Tars framework
&& mkdir -p /tmp/Tars \
&& cd /tmp/Tars \
&& mkdir -p /data \
&& chmod u+x /tmp/Tars/framework/build/build.sh \
&& cd /tmp/Tars/framework/build/ \
&& ./build.sh all \
&& ./build.sh install \
&& cp -rf /tmp/Tars/web /usr/local/tars/cpp/deploy/ \
&& cd /tmp \
# Install node environment
&& wget https://github.com/nvm-sh/nvm/archive/v0.35.1.zip \
&& unzip v0.35.1.zip \
&& cp -rf /tmp/nvm-0.35.1 /root/.nvm \
&& echo ". /root/.nvm/nvm.sh" >> /root/.bashrc \
&& echo ". /root/.nvm/bash_completion" >> /root/.bashrc \
&& source /root/.bashrc \
&& nvm install v12.13.0 \
&& npm install -g npm pm2 \
&& source $HOME/.bashrc \
# Clean build dependents
&& rm -rf /tmp/* \
&& yum remove -y yum-utils unzip git glibc-devel ncurses-devel protobuf-devel zlib-devel openssl-devel \
&& yum autoremove -y \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& ${TARS_INSTALL}/tar-server.sh

ENTRYPOINT [ "/usr/local/tars/cpp/deploy/docker-init.sh" ]

EXPOSE 3000
EXPOSE 3001

0 comments on commit 1b650ec

Please sign in to comment.