Skip to content

Commit

Permalink
CLI: compatibility of benchmark script and apisix reload command on O…
Browse files Browse the repository at this point in the history
…SX (#1650)
  • Loading branch information
qiukeren authored Jun 6, 2020
1 parent 171db26 commit 52fa154
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion benchmark/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function onCtrlC () {
sudo openresty -p $PWD/benchmark/server -s stop || exit 1
}

sed -i "s/worker_processes [0-9]*/worker_processes $worker_cnt/g" conf/nginx.conf
if [[ "$(uname)" == "Darwin" ]]; then
sed -i "" "s/worker_processes .*/worker_processes $worker_cnt;/g" conf/nginx.conf
else
sed -i "s/worker_processes .*/worker_processes $worker_cnt;/g" conf/nginx.conf
fi

make run

sleep 3
Expand Down
14 changes: 9 additions & 5 deletions bin/apisix
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,17 @@ end

function _M.reload()
local test_cmd = openresty_args .. [[ -t -q ]]
if os.execute((test_cmd)) ~= 0 then
-- When success,
-- On linux, os.execute returns 0,
-- On macos, os.execute returns 3 values: true, exit, 0, and we need the first.
local test_ret = os.execute((test_cmd))
if (test_ret == 0 or test_ret == true) then
local cmd = openresty_args .. [[ -s reload]]
-- print(cmd)
os.execute(cmd)
return
end

local cmd = openresty_args .. [[ -s reload]]
-- print(cmd)
os.execute(cmd)
print("test openresty failed")
end

function _M.version()
Expand Down

0 comments on commit 52fa154

Please sign in to comment.