PhxQueue
{% include JB/setup %}
Third Party Dependence
apt-get update && apt-get install -y build-essential cmake libtool python-dev libncurses-dev libreadline-dev libz-dev gdb ssh net-tools netcat tcpdump vim neovim
apt list --installed
gflags
cd gflags-2.2.1/
mkdir cmake_build && cd cmake_build/
CXXFLAGS=-fPIC cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..
make
make test
make install
cd -
Google Test (1.7.0 or Older Version)
cd googletest-release-1.7.0/
vi README
g++ -isystem include -I. -pthread -c src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
cd -
google-glog
cd glog-0.3.5/
vi README
./autogen.sh
./configure CXXFLAGS=-fPIC --prefix=$HOME/local --with-gflags=$HOME/local
make
make install
cd -
Modify log file name
In glog\src\logging.cc
modify LogFileObject::CreateLogfile
Google Mock (1.7.0 or Older Version)
cd googlemock-release-1.7.0/
vi README
ln -s ~/local/src/googletest-release-1.7.0 gtest
autoreconf -fvi
cd make/
make
cd -
Proto Buffers
cd protobuf-3.5.1/
vi src/README
./autogen.sh
./configure CXXFLAGS=-fPIC --prefix=$HOME/local
make
make check
make install
sudo ldconfig
cd -
LevelDB
cd leveldb-1.20/
make
make check
ln -s out-static lib
cd -
Boost (1.56 Version)
cd boost_1_56_0/
./bootstrap.sh --prefix=$HOME/local
./b2
./b2 install
cd -
Component
libco
git clone https://github.com/Tencent/libco.git
cd libco/
make
cd -
PhxPaxos
git clone https://github.com/Tencent/phxpaxos.git
pushd .
cd phxpaxos/
rm -r third_party/gflags/
rm -r third_party/glog/
rm -r third_party/gmock/
rm -r third_party/protobuf/
rm -r third_party/leveldb/
ln -s ~/local third_party/gflags
ln -s ~/local third_party/glog
ln -s ~/local/src/googlemock-release-1.7.0 third_party/gmock
ln -s ~/local third_party/protobuf
ln -s ~/local/src/leveldb-1.20 third_party/leveldb
./autoinstall.sh
make
make install
cd plugin/
make
make install
popd
PhxRPC
git clone https://github.com/Tencent/phxrpc.git
cd phxrpc/
mkdir third_party
ln -s ~/local third_party/boost
ln -s ~/local third_party/protobuf
cd -
build debug
make debug=y
make boost debug=y
or add debug = y
to phxrpc.mk
then make
cd sample/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/boost/stage/lib ./search_main -c search_server.conf
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/boost/stage/lib ./search_tool_main -c search_client.conf -f PhxMqttPublish -s "test213"
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/boost/stage/lib ./search_tool_main -c search_client.conf -f PhxEcho -s "test456"
PhxSQL
Download percona-server-5.6.31-77.0.tar.gz
MUST extract to phxsql/percona
. ln -s
is not allowed.
sudo apt-get install cmake libncurses-dev libreadline-dev libz-dev
git clone https://github.com/Tencent/phxsql.git
cd phxsql/
rm -r third_party/gflags/
rm -r third_party/glog/
rm -r third_party/protobuf/
rm -r third_party/leveldb/
ln -s ~/local third_party/gflags
ln -s ~/local third_party/glog
ln -s ~/local third_party/protobuf
ln -s ~/local/src/leveldb-1.20 third_party/leveldb
rm -r third_party/colib/
rm -r third_party/phxpaxos/
rm -r third_party/phxrpc/
ln -s ~/local/src/libco third_party/colib
ln -s ~/local/src/phxpaxos third_party/
ln -s ~/local/src/phxrpc third_party/
./autoinstall.sh
# percona may require link `libz.so`, `libz.a` to `libzlib.so`, `libzlib.a`
sudo apt-get install libz-dev
sudo apt-get install apt-file
apt-file update
apt-file list libz-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libz.so libzlib.so
sudo ln -s libz.a libzlib.a
make
# if percona has compile error cause by -Werror=implicit-fallthrough=, -Werror=nonnull-compare, -Wimplicit-fallthrough
# just comment out these lines
make install
make package
cd -
PhxQueue
git clone https://github.com/Tencent/phxqueue.git
cd phxqueue/
rm -r third_party/gflags/
rm -r third_party/glog/
rm -r third_party/protobuf/
rm -r third_party/leveldb/
ln -s ~/local third_party/gflags
ln -s ~/local third_party/glog
ln -s ~/local third_party/protobuf
ln -s ~/local/src/leveldb-1.20 third_party/leveldb
rm -r third_party/colib/
rm -r third_party/phxpaxos/
rm -r third_party/phxrpc/
ln -s ~/local/src/libco third_party/colib
ln -s ~/local/src/phxpaxos third_party/
ln -s ~/local/src/phxrpc third_party/
make debug=y
make install
cd -
Docker
docker pull buildpack-deps:artful
docker run -it -w /phx -v ~/phx:/phx -p 1883:1883 --name=phx_1 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined phx
docker cp test_file IMAGE_NAME:/test_directory
docker port phx_1 1883
nc -p 1883 -l -vv
Test connection from macOS
nc localhost 1883 -v
Change [EventLoopServer]
: BindIP
in mqttbroker_server.conf
to real ip address. Don't use 127.0.0.1
!
./mqttbroker_main -c mqttbroker_server.conf
warning: Error disabling address space randomization: Operation not permitted
apt-get update
apt-get install -y cmake --no-install-recommends
apt-get install python-dev
Submodule
Submodule Overview
git submodule
if has -
before commit id: has not been checked out
Add Submodule
git submodule add https://github.com/gflags/gflags third_party/gflags
git submodule add https://github.com/google/glog third_party/glog
git submodule add https://github.com/google/protobuf third_party/protobuf
git submodule add https://github.com/google/leveldb third_party/leveldb
git submodule add https://github.com/google/googlemock third_party/gmock
git submodule add https://github.com/taohexxx/phxrpc third_party/phxrpc
Remove Submodule
git submodule deinit -f -- third_party/glog
rm -rf .git/modules/third_party/glog
git rm -f third_party/glog
git submodule deinit -f -- third_party/phxrpc
rm -rf .git/modules/third_party/phxrpc
git rm -f third_party/phxrpc
Change Submodule Version
git submodule update --init --recursive
cd third_party/glog
git checkout v0.3.5 # if Detached HEAD, never mind
git status
git add third_party/glog
Branch
Branch Overview
# show tracking branch
git branch -vv
# show all branch
git branch -a
Merge
rebase remote branch
git fetch tencent
git co tencent_master
git rebase tencent/master
cherry-pick
git cherry-pick <commit>
http://jaskey.github.io/blog/2015/12/22/git-cherry-pick/
日志文件加载查问题
phxqueue/phxqueue_phxrpc/plugin/configfactory.cpp
impl_->global_config_path
为global配置文件路径