rpc请求thrift 环境搭建

背景

负责的项目由http请求转为thrift请求,需要搭建 thrift环境,node端处理thrift请求打到后端

搭建

  • 官方地址

官方地址
官方仓库

  • 安装

1
2
3
4
5
6
7
8
brew install boost
brew install Bison
brew install libtool
brew install automake
# 如果系统没有安装openssl
brew install openssl
brew install pkg-config
cp /usr/local/Cellar/pkg-config/0.29.2/share/aclocal/pkg.m4 ./aclocal/
  • 编译

1
2
3
4
5
./bootstrap.sh
# 由于 python 在 mac 下的路径权限问题无法解决,先忽略掉 python
./configure LDFLAGS='-L/usr/local/opt/openssl/lib' CPPFLAGS='-I/usr/local/opt/openssl/include' --without-php --without-python --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local
make
make install

1、如果pkg-config 没有安装,会如下错误“./configure: line 16976: syntax error near unexpected token `QT,’”
2、出现 fatal error: ‘openssl/opensslv.h’ file not found,需要在configure 中指定 openssl 的查找路径 ./configure LDFLAGS=’-L/usr/local/opt/openssl/lib’ CPPFLAGS=’-I/usr/local/opt/openssl/include’

  • 使用

1
thrift -r --gen js:node my_file.thrift