From 3b16fce060fbac39ee054784213a6bc81df526fc Mon Sep 17 00:00:00 2001 From: theweakgod <1031205858@qq.com> Date: Fri, 20 Oct 2023 15:49:29 +0800 Subject: [PATCH] fix(consul): worker will not exit while reload or quit (#10342) --- apisix/discovery/consul/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apisix/discovery/consul/init.lua b/apisix/discovery/consul/init.lua index 253d0cb8cebd..32e306709e95 100644 --- a/apisix/discovery/consul/init.lua +++ b/apisix/discovery/consul/init.lua @@ -32,6 +32,7 @@ local ngx_timer_every = ngx.timer.every local log = core.log local json_delay_encode = core.json.delay_encode local ngx_worker_id = ngx.worker.id +local exiting = ngx.worker.exiting local thread_spawn = ngx.thread.spawn local thread_wait = ngx.thread.wait local thread_kill = ngx.thread.kill @@ -276,7 +277,7 @@ end local function check_keepalive(consul_server, retry_delay) - if consul_server.keepalive then + if consul_server.keepalive and not exiting() then local ok, err = ngx_timer_at(0, _M.connect, consul_server, retry_delay) if not ok then log.error("create ngx_timer_at got error: ", err)