jiangfucheng commented on code in PR #9909: URL: https://github.com/apache/apisix/pull/9909#discussion_r1285900637
########## apisix/core/config_etcd.lua: ########## @@ -257,6 +260,33 @@ local function run_watch(premature) end +local function run_watch(premature) + local run_watch_th = ngx_thread_spawn(do_run_watch, premature) + + ::restart:: + local check_worker_th = ngx_thread_spawn(function () + while not exiting() do + ngx_sleep(0.1) + end + end) + + local ok, err = ngx_thread_wait(check_worker_th) + + if not ok then + log.error("wait worker checker failed, retart checker, error: " .. err) + ngx_thread_kill(check_worker_th) + goto restart + end + + -- waiting for do_run_watch thread to handle the final etcd event + ngx_sleep(1) Review Comment: After we execute `make quit` command, the admin API will not be available, so before the admin API becomes unavailable, we can use`sleep(1)` to wait for the `do_run_watch` thread to handle the last possible event. Even if no events come, we also will kill the `do_run_watch` thread. And, check `ngx.exiting` in `do_run_watch` it means we need to wait for the `res_func()` function timeout, that's why I create two threads to handle it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org