Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: apisix restart failed (#10495) #10696

Merged
merged 14 commits into from
Jan 3, 2024
Merged
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apisix/cli/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ local function start(env, ...)
local ok, err, err_no = signal.kill(pid, signone)
if ok then
print("APISIX is running...")
hanqingwu marked this conversation as resolved.
Show resolved Hide resolved
print("the old process is still running, the new one won't be started!")
hanqingwu marked this conversation as resolved.
Show resolved Hide resolved
return
-- no such process
elseif err_no ~= errno.ESRCH then
Expand Down Expand Up @@ -916,10 +917,32 @@ local function stop(env)
end


local function sleep(n)
execute("sleep " .. tonumber(n))
end

monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved

local function wait_stop_finish(env, n)
for i = 1, n do
monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved
-- check running
local pid_path = env.apisix_home .. "/logs/nginx.pid"
local pid = util.read_file(pid_path)
pid = tonumber(pid)
if not pid then
print("old apisix process has stopped")
hanqingwu marked this conversation as resolved.
Show resolved Hide resolved
return
else
sleep(1)
end
end
end
monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved


local function restart(env)
-- test configuration
test(env)
stop(env)
wait_stop_finish(env, 3)
hanqingwu marked this conversation as resolved.
Show resolved Hide resolved
start(env)
end

Expand Down
Loading