作者回复: while True 的循环吗?我的建议是跑一段时间,比如 5 分钟,就退掉,然后启动一个新的客户端。
作者回复: 特权进程和master 进程的权限一样,如果 master 是普通用户,那特权进程也不可能拿到 root 权限。
一般用特权进程来清理日志、重启 OpenResty 自身等需要高权限的任务。
作者回复: 是的,没错
作者回复: 是可以混用的,它们之间不会互相影响的。如果你确定这里有bug,可以整理一个最小的复现代码,给 OpenResty 提交 issue
作者回复: 磁盘 IO 没有什么优化的方法,这里有一个使用 nginx threads pool 来模拟实现 "非阻塞"的方案:https://github.com/tokers/lua-io-nginx-module,你可以参考下。
作者回复: 可以 while true,但是有一个阈值,比如循环 1000 次之后退出循环,重新来一次。
作者回复: 泄漏这个词可能不太恰当,就是会导致很多 Lua 或者 C 对象无法得到释放,长期运行会有很多碎片。
作者回复: ngx.timer 的文档是有提到它的作用的:
the premature argument takes a boolean value indicating whether it is a premature timer expiration or not.
Premature timer expiration happens when the Nginx worker process is trying to shut down, as in an Nginx configuration reload triggered by the HUP signal or in an Nginx server shutdown. When the Nginx worker is trying to shut down, one can no longer call ngx.timer.at to create new timers with nonzero delays and in that case ngx.timer.at will return a "conditional false" value and a string describing the error, that is, "process exiting".
简单的说,就是在 Nginx 重启后者关闭的时候,就不要再去创建 timer 了。
作者回复: 是的,没错