From 08ea27002154b888ef824c716c9d481d9d41d5d5 Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 2 Jun 2021 18:17:10 +0800 Subject: [PATCH] feat(cli): wrap nginx quit cmd Signed-off-by: spacewander --- apisix/cli/ops.lua | 18 +++++++++++++++++- ci/linux_apisix_master_luarocks_runner.sh | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index bf31eb628159..83229b4600f1 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -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 @@ -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 @@ -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 @@ -730,6 +745,7 @@ local action = { init_etcd = etcd.init, start = start, stop = stop, + quit = quit, restart = restart, reload = reload, } diff --git a/ci/linux_apisix_master_luarocks_runner.sh b/ci/linux_apisix_master_luarocks_runner.sh index c889ed2910f0..337b4c4936f7 100755 --- a/ci/linux_apisix_master_luarocks_runner.sh +++ b/ci/linux_apisix_master_luarocks_runner.sh @@ -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) @@ -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