init_worker_by_lua_file不检测文件是否存在

125 views
Skip to first unread message

tylerpiece

unread,
Sep 15, 2017, 12:02:04 AM9/15/17
to openresty
今天在写worker.lua的时候发现不会执行。
然后竟然发现我随便写一个lua名,配置文件都不会报错,像是没有去读取这个文件。
 
 
 
但是我改init.lua的名字,他会说检查不到文件。

openresty的版本信息:
resty 0.12
nginx version: openresty/1.9.15.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/home/tyler/openresty/nginx --with-debug --with-cc-opt='-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -O2' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.59 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.30 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.05 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.5 --add-module=../ngx_lua_upstream-0.05 --add-module=../headers-more-nginx-module-0.30 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.17 --add-module=../redis2-nginx-module-0.13 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/home/tyler/openresty/luajit/lib --with-http_realip_module --with-pcre --with-pcre-jit --add-module=/home/tyler/openresty-1.9.15.1/bundle/ngx_cache_purge-2.3 --add-module=/home/tyler/openresty-1.9.15.1/bundle/nginx_upstream_check_module-0.3.0 --add-module=/home/tyler/openresty-1.9.15.1/bundle/stream-lua-nginx-module-master --with-stream --with-http_ssl_module --add-module=/home/tyler/openresty-1.9.15.1/bundle/ngx_http_lower_upper_case-master


 

tokers

unread,
Sep 15, 2017, 1:55:29 AM9/15/17
to openresty
init_worker_by_lua_file 对应的文件不存在,这个会打错误日志的。
这个阶段比较特殊,Lua 代码运行在 pcall 里面,抛异常也不会影响 nginx 进入事件循环处理请求。

init_by_lua 这个阶段的代码实际运行在模块的 postconfiguration 回调里,worker 进程还没有 fork 出来,目前 ngx_lua 的设计是该阶段代码运行出问题就会使得 master 退出。

tylerpiece

unread,
Sep 15, 2017, 2:11:21 AM9/15/17
to open...@googlegroups.com

是的,我原来使用也是会打错误日志的。这下不知道为什么他就通过了。纳闷了一早上,还再找原因。
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subs...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+unsub...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html


 

tylerpiece

unread,
Sep 15, 2017, 3:13:48 AM9/15/17
to open...@googlegroups.com
是我错了,看懂了。这个文件的检测是在pcall里面,报错是会有日志,但是不会让程序退出。
Reply all
Reply to author
Forward
0 new messages