Ratel is a api server solution using c/c++:sunglasses:. It is based on spawn-fcgi, fastcgi, fastcgi++, boost and many other libraries which can achieve through github.
-
spawn-fcgi
ratel/app fork process via spawn-fcgi. -
fcgi or fastcgi
A blocking fastcgi based network library. Because of the feature of blocking, Ratel discard, and here just take it to compare with the next non-blocking network library. -
fastcgi++
A non-blocking fastcgi based network library with c++14, which means our compiler must be support c++14. One receiver-thread(as producer) accept request asynchronously, and push all request to a container which other multi-thread(act as consumer) pull from and handle. -
log
1.The log module in ratel is based on boost.log, and version must be at least 1.54.0.
2.Instead of verboss "<<", it use printf-style syntax:sunglasses:, which means we can log like this:
Log(info, "Num:%d, note:%s", 1, "log here");
-
jsoncpp
Before jsoncpp, i tried boost.ptree and rapidJson. However boost.ptree does not conform to JSON standard and rapidJson is extremely clunky to use. As for jsoncpp, the fact that Serialize UTF-8 string with Unicode escapes #687 since v1.8.4 seems to be useless:disappointed_relieved:. So, here i will stay with v1.8.3 until it makes some change. -
mysqlwrapper
A mysql-connector based sql wrapper which makes mysql easier to use.
On Ubuntu 14.04, start with the following steps:
# 1. Add toolchain repo:
$ sudo apt-add-repository "ppa:ubuntu-toolchain-r/test"
$ sudo apt-get update
# 2. Install toolchain
$ sudo apt-get install gcc-7 g++-7
# 3. Enable gcc7:
$ sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc -f
$ sudo ln -s /usr/bin/g++-7 /usr/bin/g++ -f
# 4. The default boost repo version on ubuntu 14.04 is 1.54.0:
$ sudo apt-get install libboost-log1.54-dev \
libboost-system1.54-dev \
libboost-thread1.54-dev \
libboost-filesystem1.54-dev
# 5. Install mysql-connector-c++
$ wget https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-1.1.9-linux-ubuntu14.04-x86-64bit.tar.gz
$ tar -xzvf mysql-connector-c++-1.1.9-linux-ubuntu14.04-x86-64bit.tar.gz
$ sudo cp -drf mysql-connector-c++-1.1.9-linux-ubuntu14.04-x86-64bit/lib/* /usr/lib
If CentOS7.4, you can get started in five steps:
# 1. Install a package with repository for your system:
$ sudo yum install centos-release-scl-rh
# 2. Install the collection:
$ sudo yum install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gdb
# 3. Start using software collections:
$ source /opt/rh/devtoolset-7/enable
# 4. The default boost from yum on centos7.4 is 1.53.0, we have to download 1.54.0 and build.
$ cd ~
$ wget -q https://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz
$ tar -xzf boost_1_54_0.tar.gz
$ cd boost_1_54_0
$ ./bootstrap.sh
$ ./b2 --with-log --with-thread --with-system --with-filesystem
$ sudo cp -drf boost /usr/include
$ sudo cp -drf stage/lib/* /usr/lib64
# 5. Install mysql-connector-c++
$ wget https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-1.1.9-linux-el7-x86-64bit.tar.gz
$ tar -xzvf mysql-connector-c++-1.1.9-linux-el7-x86-64bit.tar.gz
$ sudo cp -drf mysql-connector-c++-1.1.9-linux-el7-x86-64bit/lib/* /usr/lib64
Then, clone and make like this:
$ git clone https://github.com/xujintao/ratel
$ cd ratel
$ ./build.sh
$ ./restart.sh
Now, it should be running well locally. Next we will show how to deploy it to field server by travis-ci.
-
Travis-CI git ratel project clone from github, building with the help of docker4cpp container, and then package all the result directely to test/product server or build runtime images to docker hub.
-
c++ runtime
runtime | CentOS7.4 | ubuntu14.04 |
---|---|---|
libc | /usr/lib64/libc-2.17.so (2012.12.25) | /lib/x86_64-linux-gnu/libc-2.19.so (2014.2.7) |
libstdc++(c++11) | /usr/lib64/libstdc++.so.6.0.19 (2014.5.22) | /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 (2014.5.22) |
libstdc++(c++17) | /opt/rh/devtoolset-7/.../x86_64-redhat-linux/7/* (2017-12-25) | /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24 (2017.8.20) |