Skip to content

Commit

Permalink
Merge pull request #1 from apache/master
Browse files Browse the repository at this point in the history
update apache/incubator-apisix
  • Loading branch information
Miss-you authored Feb 6, 2020
2 parents 7dcdeb4 + 5fff97d commit 446cba4
Show file tree
Hide file tree
Showing 27 changed files with 1,417 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ matrix:
fast_finish: true
allow_failures:
- os: osx
- env: OSNAME=linux_apisix_luarocks

include:
- os: linux
Expand All @@ -22,6 +23,8 @@ matrix:
services:
- redis-server
env: OSNAME=linux_tengine
- os: linux
env: OSNAME=linux_apisix_luarocks

language: c

Expand Down
1 change: 0 additions & 1 deletion .travis/ASF-Release.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ grpc_server_example
.travis.yml
grpcurl
t/servroot
grpcurl

conf
.travis/openwhisk-utilities
Expand Down
74 changes: 74 additions & 0 deletions .travis/linux_apisix_luarocks_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -ex

export_or_prefix() {
export OPENRESTY_PREFIX="/usr/local/openresty-debug"
}

do_install() {
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
sudo apt-get -y update --fix-missing
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo add-apt-repository -y ppa:longsleep/golang-backports

sudo apt-get update
sudo apt-get install openresty-debug
}

script() {
export_or_prefix
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH
openresty -V
sudo service etcd start

# install APISIX by shell
sudo mkdir -p /usr/local/apisix/deps
sudo PATH=$PATH ./utils/install-apisix.sh install

sudo apisix help
sudo apisix init
sudo apisix start
sudo apisix stop

sudo PATH=$PATH ./utils/install-apisix.sh remove

# install APISIX by luarocks
sudo luarocks install rockspec/apisix-master-0.rockspec

sudo apisix help
sudo apisix init
sudo apisix start
sudo apisix stop

sudo luarocks remove rockspec/apisix-master-0.rockspec
}

case_opt=$1
shift

case ${case_opt} in
do_install)
do_install "$@"
;;
script)
script "$@"
;;
esac
2 changes: 0 additions & 2 deletions .travis/linux_tengine_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ tengine_install() {
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-cache_manager_exit.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-daemon_destroy_pool.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-delayed_posted_events.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-gcc-maybe-uninitialized-warning.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-hash_overflow.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-init_cycle_pool_release.patch
wget -P patches https://raw.githubusercontent.com/openresty/openresty/master/patches/nginx-1.17.4-larger_max_error_str.patch
Expand All @@ -102,7 +101,6 @@ tengine_install() {
patch -p1 < ../../patches/nginx-1.17.4-cache_manager_exit.patch
patch -p1 < ../../patches/nginx-1.17.4-daemon_destroy_pool.patch
patch -p1 < ../../patches/nginx-1.17.4-delayed_posted_events.patch
patch -p1 < ../../patches/nginx-1.17.4-gcc-maybe-uninitialized-warning.patch
patch -p1 < ../../patches/nginx-1.17.4-hash_overflow.patch
patch -p1 < ../../patches/nginx-1.17.4-init_cycle_pool_release.patch
patch -p1 < ../../patches/nginx-1.17.4-larger_max_error_str.patch
Expand Down
76 changes: 76 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,82 @@ Once we've discussed your changes and you've got your code ready, make sure that
* References the original issue in description, e.g. "Resolves #123".
* Has a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

## Contribution Guidelines for Documentation

* Active Voice

In general use active voice when formulating the sentence instead of passive voice. A sentence written in the active voice will emphasize
the person or thing who is performing an action (eg.The dog chased the ball). In contrast, the passive voice will highlight
the recipient of the action (The ball was chased by the dog). Therefor use the passive voice, only when it's less important
who or what completed the action and more important that the action was completed. For example:

- Recommended: The key-auth plugin authenticates the requests.
- Not recommended: The requests are authenticated by the key-auth plugin.

* Capitalization:

* For titles of a section, capitalize the first letter of each word except for the [closed-class words](http://babelnet.sbg.ac.at/themepark/grammar/classes.htm)
such as determiners, pronouns, conjunctions, and prepositions. Use the following [link](https://capitalizemytitle.com/#Chicago) for guidance.
- Recommended: Authentication **with** APISIX

* For normal sentences don't [capitalize](https://www.grammarly.com/blog/capitalization-rules/) random words in the middle of the sentences.
Use the Chicago manual for capitalization rules for the documentation.

* Second Person

In general, use second person in your docs rather than first person. For example:

- Recommended: You are recommended to use the docker based deployment.
- Not Recommended: We recommend to use the docker based deployment.

* Spellings

Use [American spellings](https://www.oxfordinternationalenglish.com/differences-in-british-and-american-spelling/) when
contributing to the documentation.

* Voice

* Use a friendly and conversational tone. Always use simple sentences. If the sentence is lengthy try to break it in to smaller sentences.

## Check code style and test case style

* code style
* Please take a look at [OpenResty Lua Coding Style Guide](CODE_STYLE.md).
* Use tool to check your code statically by command: `make lint`.
```shell
# install `luacheck` first before run it
$ luarocks install luacheck
# check source code
$ make lint
luacheck -q lua
Total: 0 warnings / 0 errors in 74 files
./utils/lj-releng lua/*.lua \
lua/apisix/*.lua \
lua/apisix/admin/*.lua \
lua/apisix/core/*.lua \
lua/apisix/http/*.lua \
lua/apisix/http/router/*.lua \
lua/apisix/plugins/*.lua \
lua/apisix/plugins/grpc-transcode/*.lua \
lua/apisix/plugins/limit-count/*.lua > \
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
```
* test case style
* Use tool to check your test case style statically by command, eg: `reindex t/admin/*.t`.
```shell
# install `reindex` first before run it
# wget https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/reindex
# ./reindex test cases
$ reindex t/admin/*.t
reindex: t/plugin/example.t: skipped. # No changes needed
reindex: t/plugin/fault-injection.t: done. # updated
reindex: t/plugin/grpc-transcode.t: skipped.
... ...
reindex: t/plugin/udp-logger.t: done.
reindex: t/plugin/zipkin.t: skipped.
```
* By the way, we can download "reindex" to another path and add this path to "PATH" environment.

## Do you have questions about the source code?

- **QQ group**: 552030619
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,7 @@ install:

### test: Run the test case
test:
ifeq ($(UNAME),Darwin)
prove -I../test-nginx/lib -I./ -r -s t/
else
prove -I../test-nginx/lib -r -s t/
endif


### license-check: Check Lua source code for Apache License
.PHONY: license-check
Expand Down
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ A/B testing, canary release, blue-green deployment, limit rate, defense against
- **Multi protocols**
- [TCP/UDP Proxy](doc/stream-proxy.md): Dynamic TCP/UDP proxy.
- [Dynamic MQTT Proxy](doc/plugins/mqtt-proxy.md): Supports to load balance MQTT by `client_id`, both support MQTT [3.1.*](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html), [5.0](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html).
- [gRPC proxy](doc/grpc-proxy.md)Proxying gRPC traffic.
- [gRPC transcoding](doc/plugins/grpc-transcoding.md)Supports protocol transcoding so that clients can access your gRPC API by using HTTP/JSON.
- [gRPC proxy](doc/grpc-proxy.md): Proxying gRPC traffic.
- [gRPC transcoding](doc/plugins/grpc-transcoding.md): Supports protocol transcoding so that clients can access your gRPC API by using HTTP/JSON.
- Proxy Websocket
- Proxy Dubbo: Dubbo Proxy based on Tengine.
- HTTP(S) Forward Proxy
Expand All @@ -69,7 +69,7 @@ A/B testing, canary release, blue-green deployment, limit rate, defense against
- [Serverless](doc/plugins/serverless.md): Invoke functions in each phase in APISIX.
- Dynamic Load Balancing: Round-robin load balancing with weight.
- Hash-based Load Balancing: Load balance with consistent hashing sessions.
- [Health Checks](doc/health-check.md)Enable health check on the upstream node, and will automatically filter unhealthy nodes during load balancing to ensure system stability.
- [Health Checks](doc/health-check.md): Enable health check on the upstream node, and will automatically filter unhealthy nodes during load balancing to ensure system stability.
- Circuit-Breaker: Intelligent tracking of unhealthy upstream services.

- **Fine-grained routing**
Expand Down Expand Up @@ -138,20 +138,23 @@ you can follow the [documentation of limit count](doc/plugins/limit-count.md).
Then you can try more [plugins](doc/README.md#plugins).

## Dashboard
APISIX has built-in support for dashboards, as follows:
APISIX has built-in support for Dashboard, as follows:

- Download the source code of [dashboard](https://github.com/apache/incubator-apisix-dashboard):
1. Please make sure your machine has Node 8.x or higher, or there will occur build issues.

2. Download the source codes of [Dashboard](https://github.com/apache/incubator-apisix-dashboard):
```
git clone https://github.com/apache/incubator-apisix-dashboard.git
```
- install yarn: refer to [documentation](https://yarnpkg.com/en/docs/install)
- Install dependencies and build

3. Install [yarn](https://yarnpkg.com/en/docs/install)

4. Install dependencies then run build command:
```
yarn
yarn run build:prod
yarn && yarn build:prod
```

- Integration with APISIX
5. Integration with APISIX
Copy the compiled files under `/dist` directory to the `apisix/dashboard` directory,
open `http://127.0.0.1:9080/apisix/dashboard/` in the browser.
Do not need to fill the user name and password, log in directly.
Expand Down Expand Up @@ -208,13 +211,8 @@ Using AWS's 8 core server, APISIX's QPS reach to 140,000 with a latency of only
| Support any Nginx variable as routing condition | Yes | No |

## Videos And Articles
- 2019.12.14 [From 0 to 1: APISIX's Apache travel(Chinese)](https://zhuanlan.zhihu.com/p/99620158)
- 2019.12.14 [Next-generation microservice architecture based on Apache APISIX(Chinese)](https://www.upyun.com/opentalk/445.html)
- 2019.10.30 [Introduction to Apache APISIX Microservice Gateway Extreme Performance Architecture(Chinese)](https://www.upyun.com/opentalk/440.html)
- 2019.9.27 [Want to run APISIX on an ARM64 platform? Just three steps(Chinese)](https://zhuanlan.zhihu.com/p/84467919)
- 2019.8.31 [APISIX technology selection, testing and continuous integration(Chinese)](https://www.upyun.com/opentalk/433.html)
- 2019.8.31 [APISIX high performance practice 2(Chinese)](https://www.upyun.com/opentalk/437.html)
- 2019.7.6 [APISIX high performance practice(Chinese)](https://www.upyun.com/opentalk/429.html)
- [APISIX technology selection, testing and continuous integration](https://medium.com/@ming_wen/apache-apisixs-technology-selection-testing-and-continuous-integration-313221b02542)
- [Analysis of Excellent Performance of Apache APISIX Microservices Gateway](https://medium.com/@ming_wen/analysis-of-excellent-performance-of-apache-apisix-microservices-gateway-fc77db4090b5)

## User Stories
- [ke.com: How to Build a Gateway Based on Apache APISIX(Chinese)](https://mp.weixin.qq.com/s/yZl9MWPyF1-gOyCp8plflA)
Expand Down
15 changes: 9 additions & 6 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,21 @@ sudo apisix start

APISIX 内置了对 Dashboard 的支持,使用步骤如下:

- 下载 [Dashboard](https://github.com/apache/incubator-apisix-dashboard) 的源码:
1. 确保你的运行环境中的 Node 版本高于或等于 8.x。

2. 下载 [Dashboard](https://github.com/apache/incubator-apisix-dashboard) 的源码:
```
git clone https://github.com/apache/incubator-apisix-dashboard.git
```
- 安装yarn: 参考[安装文档](https://yarnpkg.com/zh-Hans/docs/install)
- 安装依赖并构建

3. 安装 [yarn](https://yarnpkg.com/zh-Hans/docs/install)

4. 安装依赖并构建
```
yarn
yarn run build:prod
yarn && yarn build:prod
```

- 与 APISIX 集成
5. 与 APISIX 集成
把编译后的在 `/dist` 目录下的所有文件,拷贝到 `apisix/dashboard` 目录下。
使用浏览器打开 `http://127.0.0.1:9080/apisix/dashboard/` 即可使用,
不用填写用户名和密码,直接登录。
Expand Down
28 changes: 26 additions & 2 deletions bin/apisix
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ worker_cpu_affinity auto;
error_log {* error_log *} {* error_log_level or "error" *};
pid logs/nginx.pid;
worker_rlimit_nofile 20480;
worker_rlimit_nofile {* worker_rlimit_nofile *};
events {
accept_mutex off;
worker_connections {* event.worker_connections *};
}
worker_rlimit_core 500M;
worker_rlimit_core {* worker_rlimit_core *};
working_directory /tmp/apisix_cores/;
worker_shutdown_timeout 3;
Expand Down Expand Up @@ -437,6 +437,17 @@ local function get_openresty_version()
return nil
end

local function is_32bit_arch()
local ok, ffi = pcall(require, "ffi")
if ok then
-- LuaJIT
return ffi.abi("32bit")
end
local ret = excute_cmd("getconf LONG_BIT")
local bits = tonumber(ret)
return bits <= 32
end

local function split(self, sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
Expand Down Expand Up @@ -517,13 +528,26 @@ local function init()
error("failed to read `nginx_config` field from yaml file")
end

if is_32bit_arch() then
sys_conf["worker_rlimit_core"] = "4G"
else
sys_conf["worker_rlimit_core"] = "16G"
end

for k,v in pairs(yaml_conf.apisix) do
sys_conf[k] = v
end
for k,v in pairs(yaml_conf.nginx_config) do
sys_conf[k] = v
end

local wrn = sys_conf["worker_rlimit_nofile"]
local wc = sys_conf["event"]["worker_connections"]
if not wrn or wrn <= wc then
-- ensure the number of fds is slightly larger than the number of conn
sys_conf["worker_rlimit_nofile"] = wc + 128
end

if(sys_conf["enable_dev_mode"] == true) then
sys_conf["worker_processes"] = 1
else
Expand Down
2 changes: 2 additions & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ apisix:
nginx_config: # config for render the template to genarate nginx.conf
error_log: "logs/error.log"
error_log_level: "warn" # warn,error
worker_rlimit_nofile: 20480 # the number of files a worker process can open, should be larger than worker_connections
event:
worker_connections: 10620
http:
Expand Down Expand Up @@ -96,6 +97,7 @@ plugins: # plugin list
- response-rewrite
- fault-injection
- udp-logger
- wolf-rbac

stream_plugins:
- mqtt-proxy
4 changes: 2 additions & 2 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ Let's deconstruct the above URL.
- Scheme: HTTPS
- Host/Address: httpbin.org
- Port: 443
- URI: get
- URI: /get
- Query Parameters: foo1, foo2

## Prerequisites

- The guide uses docker and docker-compose to setup APISIX. But if you have already installed APISIX via other methods, then you can skip to step 2.
- This guide uses docker and docker-compose to setup APISIX. But if you have already installed APISIX in other ways, you can just skip to [step 2](getting-started.md#step-2-create-a-route-in-apisix).
- Curl: The guide uses curl command for API testing, but you can also use any other tool of your choice (Eg- Postman).

## Step 1: Install APISIX
Expand Down
Loading

0 comments on commit 446cba4

Please sign in to comment.