Hello!
2014-09-26 10:35 GMT-07:00 fancyrabbit:
> while true do
> local res, err = sentinel:read_reply()
> if not res and err ~= "timeout" then
> ngx.log(ngx.WARN, "failed to read reply: ", err)
> sentinel:close()
> l:unlock()
> return
> end
> if res then
> ngx.log(ngx.WARN, 'received publish')
> -- redis_check() do something to fetch the newest ip and port
> end
> end
> end
>
你应当为你的 cosocket 使用较短的 read timeout 值,比如 1 秒或几秒钟,然后自己在你的无限循环里面检查
ngx.worker.exiting() 的返回值。如果 nginx worker 已经在退出了,你应当自己终止你的循环。
https://github.com/openresty/lua-nginx-module#ngxworkerexiting
在此种情况下,优雅退出是你的责任,毕竟只有你自己知道应该如何优雅退出你的 Lua 循环。
Regards,
-agentzh