2019-07-18 16:09:30 +08:00
|
|
|
|
# 开发者手册
|
|
|
|
|
|
|
|
|
|
## 在开发环境搭建 APISIX
|
|
|
|
|
|
2019-09-16 21:40:39 +08:00
|
|
|
|
不同系统有不同依赖,查看[安装依赖](doc/install-dependencies.md)完成依赖项安装。
|
|
|
|
|
|
|
|
|
|
如果你是开发人员,可以在完成上面安装依赖项后,通过下面的命令快速搭建本地开发环境。
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2019-09-12 10:56:47 +08:00
|
|
|
|
# clone project
|
2019-07-18 16:09:30 +08:00
|
|
|
|
git clone git@github.com:iresty/apisix.git
|
|
|
|
|
cd apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
|
|
|
|
|
# init submodule
|
|
|
|
|
git submodule update --init --recursive
|
|
|
|
|
|
|
|
|
|
# install dependency
|
2019-07-18 16:09:30 +08:00
|
|
|
|
make dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
如果一切顺利,你会在最后看到这样的信息:
|
|
|
|
|
|
|
|
|
|
> Stopping after installing dependencies for apisix
|
|
|
|
|
|
|
|
|
|
下面是预期的开发环境目录结构:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
$ tree -L 2 -d apisix
|
|
|
|
|
apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
├── benchmark
|
|
|
|
|
│ ├── fake-apisix
|
|
|
|
|
│ └── server
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── bin
|
|
|
|
|
├── conf
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ └── cert
|
|
|
|
|
├── dashboard
|
|
|
|
|
│ ├── css
|
|
|
|
|
│ ├── fonts
|
|
|
|
|
│ ├── img
|
|
|
|
|
│ ├── js
|
|
|
|
|
│ └── tinymce
|
|
|
|
|
├── deps # 依赖的 Lua 和动态库,放在了这里
|
2019-07-18 16:09:30 +08:00
|
|
|
|
│ ├── lib64
|
|
|
|
|
│ └── share
|
|
|
|
|
├── doc
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── images
|
|
|
|
|
│ └── plugins
|
|
|
|
|
├── logs
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── lua
|
|
|
|
|
│ └── apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
├── rockspec
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── t
|
|
|
|
|
│ ├── admin
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── config-center-yaml
|
2019-07-18 16:09:30 +08:00
|
|
|
|
│ ├── core
|
|
|
|
|
│ ├── lib
|
|
|
|
|
│ ├── node
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── plugin
|
|
|
|
|
│ ├── router
|
|
|
|
|
│ └── servroot
|
2019-07-18 16:09:30 +08:00
|
|
|
|
└── utils
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-16 21:40:39 +08:00
|
|
|
|
## 管理(启动、关闭等)APISIX 服务
|
|
|
|
|
|
|
|
|
|
我们可以在 apisix 的目录下用 `make run` 命令来启动服务,或者用 `make stop` 方式关闭服务。
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2019-09-16 21:40:39 +08:00
|
|
|
|
# init nginx config file and etcd
|
|
|
|
|
$ make init
|
|
|
|
|
./bin/apisix init
|
|
|
|
|
./bin/apisix init_etcd
|
|
|
|
|
|
|
|
|
|
# start APISIX server
|
|
|
|
|
$ make run
|
|
|
|
|
|
|
|
|
|
# stop APISIX server
|
|
|
|
|
$ make stop
|
|
|
|
|
|
|
|
|
|
# more actions find by `help`
|
2019-07-18 16:09:30 +08:00
|
|
|
|
$ make help
|
|
|
|
|
Makefile rules:
|
|
|
|
|
|
|
|
|
|
help: Show Makefile rules.
|
|
|
|
|
dev: Create a development ENV
|
2019-09-12 10:56:47 +08:00
|
|
|
|
dev_r3: Create a development ENV for r3
|
|
|
|
|
check: Check Lua source code
|
2019-07-18 16:09:30 +08:00
|
|
|
|
init: Initialize the runtime environment
|
|
|
|
|
run: Start the apisix server
|
|
|
|
|
stop: Stop the apisix server
|
|
|
|
|
clean: Remove generated files
|
|
|
|
|
reload: Reload the apisix server
|
|
|
|
|
install: Install the apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
test: Run the test case
|
2019-07-18 16:09:30 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 运行测试案例
|
|
|
|
|
|
|
|
|
|
在你本地运行测试案例:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
make test
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
下面是运行测试的依赖项:
|
|
|
|
|
|
|
|
|
|
* Nginx: version >= 1.4.2
|
|
|
|
|
|
|
|
|
|
* Perl modules:
|
|
|
|
|
`Test::Nginx` https://github.com/openresty/test-nginx
|
|
|
|
|
|
|
|
|
|
更多细节,可以参考 [travis.yml](.travis.yml).
|