Skip to content

Commit 52fa154

Browse files
authored
CLI: compatibility of benchmark script and apisix reload command on OSX (#1650)
1 parent 171db26 commit 52fa154

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

benchmark/run.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ function onCtrlC () {
3636
sudo openresty -p $PWD/benchmark/server -s stop || exit 1
3737
}
3838

39-
sed -i "s/worker_processes [0-9]*/worker_processes $worker_cnt/g" conf/nginx.conf
39+
if [[ "$(uname)" == "Darwin" ]]; then
40+
sed -i "" "s/worker_processes .*/worker_processes $worker_cnt;/g" conf/nginx.conf
41+
else
42+
sed -i "s/worker_processes .*/worker_processes $worker_cnt;/g" conf/nginx.conf
43+
fi
44+
4045
make run
4146

4247
sleep 3

bin/apisix

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -838,13 +838,17 @@ end
838838

839839
function _M.reload()
840840
local test_cmd = openresty_args .. [[ -t -q ]]
841-
if os.execute((test_cmd)) ~= 0 then
841+
-- When success,
842+
-- On linux, os.execute returns 0,
843+
-- On macos, os.execute returns 3 values: true, exit, 0, and we need the first.
844+
local test_ret = os.execute((test_cmd))
845+
if (test_ret == 0 or test_ret == true) then
846+
local cmd = openresty_args .. [[ -s reload]]
847+
-- print(cmd)
848+
os.execute(cmd)
842849
return
843850
end
844-
845-
local cmd = openresty_args .. [[ -s reload]]
846-
-- print(cmd)
847-
os.execute(cmd)
851+
print("test openresty failed")
848852
end
849853

850854
function _M.version()

0 commit comments

Comments
 (0)