1、access_by_lua 在下面这种情况下不会被触发事件
但是 header_filter_by_lua 会不触发
server {
access_by_lua_file 'xxxxx.lua';
header_filter_by_lua_file 'yyyyy.lua';
listen 7112;
location ~* ^/ {
return 200 "ok";
break;
}
}
2、在 ngx.timer 里运行是单独的coroutine
无法获取当前文件内的变量,必须通过传参或者重新引用模块进行
比如下面代码会报错,运行在bbb里的coroutine会找不到aaa()
function aaa()
– do something
end
function bbb(premature)
aaa()
– do something
end
ngx.timer.at(0, bbb)
必须改成:
function aaa()
– do something
end
function bbb(premature)
local aaa = require “xxx”.aaa
aaa()
– do something
end
ngx.timer.at(0, bbb)