Use a small time interval (such as 1s) to complete a relatively long sleep behavior, so that the worker process can be shut down gracefully.
Here is the fake code(we may):
function sleep(sec)
if sec <= 1 then
ngx_sleep(sec)
return
end
while true do
if sec > 1 then
ngx_sleep(1)
end
if exiting() then
return
end
sec = sec - 1
if sec < 1 then
ngx_sleep(sec)
return
end
end
end
Use a small time interval (such as 1s) to complete a relatively long sleep behavior, so that the worker process can be shut down gracefully.
Here is the fake code(we may):