feature: added init action in makefile to initialize the runtime (#205)

* feature: added `init` action in makefile to initialize the runtime
  environment.
* doc: added more doc about `make` command.
* CLI: find the Lua from default PATH.
* bugfix: used short connection when to fetch node status.
This commit is contained in:
YuanSheng Wang 2019-07-05 19:01:20 +08:00 committed by GitHub
parent 764280f5ff
commit 565cb1653c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 2 deletions

View File

@ -3,6 +3,7 @@ INST_LIBDIR ?= $(INST_PREFIX)/lib64/lua/5.1
INST_LUADIR ?= $(INST_PREFIX)/share/lua/5.1
INST_BINDIR ?= /usr/bin
INSTALL ?= install
UNAME ?= $(shell uname)
.PHONY: default
@ -21,7 +22,11 @@ help:
.PHONY: dev
dev:
./utils/update_nginx_conf_dev.sh
ifeq ($(UNAME),Darwin)
luarocks install apisix-*.rockspec --tree=deps --only-deps
else
sudo luarocks install apisix-*.rockspec --tree=deps --only-deps
endif
### check: Check Lua srouce code
@ -35,6 +40,13 @@ check:
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
### init: Initialize the runtime environment
.PHONY: init
init:
./bin/apisix init
./bin/apisix init_etcd
### run: Start the apisix server
.PHONY: run
run:

View File

@ -136,6 +136,23 @@ apisix
└── utils
```
We can use more actions in the `make` command, for example:
```shell
$ make help
Makefile rules:
help: Show Makefile rules.
dev: Create a development ENV
check: Check Lua srouce code
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
```
## Quickstart
1. start server:

View File

@ -132,6 +132,23 @@ apisix
└── utils
```
`make` 可以辅助我们完成更多其他功能, 比如:
```shell
$ make help
Makefile rules:
help: Show Makefile rules.
dev: Create a development ENV
check: Check Lua srouce code
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
```
## 快速上手
1. 启动 APISIX

View File

@ -1,4 +1,4 @@
#! /usr/bin/lua
#!/usr/bin/env lua
local script_path = debug.getinfo(1).source:sub(2)

View File

@ -33,7 +33,9 @@ end
local function run_loop()
local res, err = core.http.request_self("/apisix/nginx_status")
local res, err = core.http.request_self("/apisix/nginx_status", {
keepalive = false,
})
if not res then
if err then
return core.log.error("failed to fetch nginx status: ", err)