xiaoyuwz

- Jun 2, 2022
- Joined May 26, 2022
下载了官方的RPM包:
openresty-1.21.4.1-1.el7.x86_64.rpm openresty-openssl111-1.1.1n-1.el7.x86_64.rpm openresty-pcre-8.45-1.el7.x86_64.rpm openresty-zlib-1.2.12-1.el7.x86_64.rpm
使用如下配置:
exit_worker_by_lua_block { local sock = ngx.socket.tcp() local port = 80 local ok, err = sock:connect("127.0.0.1", port) if not ok then ngx.say("failed to connect: ", err) return end ngx.say("connected: ", ok) ok, err = sock:close() ngx.say("close: ", ok, " ", err) }
错误日志如下:
2022/05/26 17:29:22 [error] 16079#16079: exit_worker_by_lua error: exit_worker_by_lua:2: API disabled in the context of exit_worker_by_lua* stack traceback: [C]: in function 'tcp' exit_worker_by_lua:2: in main chunk
nginx-1.20.2
LuaJIT-2.1-20220411
lua-nginx-module-v0.10.21
lua-resty-core-v0.1.23
lua-resty-lrucache-v0.11
使用上述版本在centos7 kernel-3.10.0-1160.21.1.el7.x86_64上使用exit_worker_by_lua_file命令,在lua中同步一个统计次数到mysql数据库,使用了mysql.lua模块,报了如下错误:
mysql.lua:520: API disabled in the context of exit_worker_by_lua*
stack traceback:
[C]: in function 'tcp'
/usr/local/nginx/script/Lua/plugins/mysql.lua:520: in function 'new'
在https://github.com/openresty/lua-nginx-module#exit_worker_by_lua_block中提到了禁用timer并没有提及是否禁用ngx.socket.tcp,麻烦确认,多谢!