agentzh <age...@gmail.com> Dec 08 12:34PM -0800
> 初学openresty,有个问题不解,
我现在nginx改成这样:
server {
listen 8080 so_keepalive=2s:2s:8;
...
location /sse {
lua_check_client_abort on;
content_by_lua '
local function sse_cleanup()
ngx.log(ngx.ERR, "client abort: " .. ngx.var.request_uri);
ngx.exit(499);
end
local ok, err = ngx.on_abort( sse_cleanup );
if not ok then
ngx.log(ngx.ERR, "failed to register the on_abort callback: ", err);
ngx.exit( ngx.HTTP_INTERNAL_SERVER_ERROR );
end
ngx.header["Content-Type"] = "text/event-stream\\n\\n";
local counter = math.random(1, 10);
while 1 do
local cur_date = os.time();
ngx.log(ngx.CRIT, "uri :" .. ngx.var.request_uri);
ngx.print("event: ping");
ngx.print("data: {\\\"time\\\":\\\"" .. cur_date .. "\\\"}");
ngx.print("\\n\\n");
counter = counter - 1;
if counter == 0 then
ngx.print("data: this is a message at time " .. cur_date .. "\\n\\n");
counter = math.random(1, 10);
end
ngx.flush( true );
ngx.sleep(1);
end
';
}
但是我发现当我用reconq浏览器建立SSE连接后,当我把浏览器关掉后,再对nginx进程发HUP信号,openresty的工作进程一直处于is shutting down状态而不能退出,但是用chrome浏览器就不会发生这种情况。
比如用reconq浏览器打开网页,在关闭浏览器,执行:
$ kill -HUP 10020
$ ps aux | grep nginx
输出:
zhen 10020 0.0 0.0 31700 2168 ? Ss 17:44 0:00 nginx: master process openresty -p /home/zhen/works/openresty/tutorial/ -c t01.conf
zhen 11547 0.0 0.0 32124 2244 ? S 19:41 0:00 nginx: worker process
is shutting down zhen 11765 0.0 0.0 32124 1552 ? S 20:30 0:00 nginx: worker process
但是用firefox或chrome浏览器则不存在该问题,不会出现那个worker process is shutting down的情况。
不知道这是不是reconq浏览器存在的bug?
--
with kind regards