Skip to content

Commit

Permalink
feat(cli): wrap nginx quit cmd (#4360)
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
  • Loading branch information
spacewander authored Jun 2, 2021
1 parent 804437f commit 0637d79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apisix/cli/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ init: initialize the local nginx.conf
init_etcd: initialize the data of etcd
start: start the apisix server
stop: stop the apisix server
quit: stop the apisix server gracefully
restart: restart the apisix server
reload: reload the apisix server
version: print the version of apisix
Expand Down Expand Up @@ -679,7 +680,7 @@ local function start(env, ...)
end


local function stop(env)
local function cleanup()
local local_conf_path = profile:yaml_path("config")
local bak_exist = io_open(local_conf_path .. ".bak")
if bak_exist then
Expand All @@ -692,6 +693,20 @@ local function stop(env)
util.die("failed to mv original config file, error: ", err)
end
end
end


local function quit(env)
cleanup()

local cmd = env.openresty_args .. [[ -s quit]]
util.execute_cmd(cmd)
end


local function stop(env)
cleanup()

local cmd = env.openresty_args .. [[ -s stop]]
util.execute_cmd(cmd)
end
Expand Down Expand Up @@ -730,6 +745,7 @@ local action = {
init_etcd = etcd.init,
start = start,
stop = stop,
quit = quit,
restart = restart,
reload = reload,
}
Expand Down
4 changes: 4 additions & 0 deletions ci/linux_apisix_master_luarocks_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ script() {
sudo PATH=$PATH apisix help
sudo PATH=$PATH apisix init
sudo PATH=$PATH apisix start
sudo PATH=$PATH apisix quit
sudo PATH=$PATH apisix start
sudo PATH=$PATH apisix stop

sudo PATH=$PATH ./utils/install-apisix.sh remove > build.log 2>&1 || (cat build.log && exit 1)
Expand All @@ -62,6 +64,8 @@ script() {
sudo PATH=$PATH apisix help
sudo PATH=$PATH apisix init
sudo PATH=$PATH apisix start
sudo PATH=$PATH apisix quit
sudo PATH=$PATH apisix start
sudo PATH=$PATH apisix stop

# apisix cli test
Expand Down

0 comments on commit 0637d79

Please sign in to comment.