nginx 在linux 不同会话间重启导致找不到 lua 文件
使用 content_by_lua ' local _arg = ngx.req.get_uri_args() local cpcode=_arg["cpcode"] local deviceid=_arg["deviceid"] local batch=_arg["batch"]; local logon= require "logon" local cjson= require "cjson" local result, status =logon.logon(cpcode,deviceid,batch,true,true); ngx.print(cjson.encode(result)); ';
结果: 2013/11/07 10:59:27 [error] 16315#0: *128120078 lua entry thread aborted: runtime error: [string "content_by_lua"]:6: module 'logon' not found: no field package.preload['logon'] no file 'lua/RouteTraffic/lib/logon.lua' no file 'lua/RouteTraffic/logon.lua' no file '/usr/local/openresty/lualib/logon.lua' no file '/usr/local/openresty/lualib/logon/init.lua' no file './logon.lua' no file '/usr/local/openresty/luajit/share/luajit-2.0.1/logon.lua' no file '/usr/local/share/lua/5.1/logon.lua' no file '/usr/local/share/lua/5.1/logon/init.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/logon.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/logon/init.lua' no file '/usr/local/openresty/lualib/logon.so' no file './logon.so' no file '/usr/local/lib/lua/5.1/logon.so' no file '/usr/local/openresty/luajit/lib/lua/5.1/logon.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: coroutine 0: [C]: in function 'require' [string "content_by_lua"]:6: in function <[string "content_by_lua"]:1>, client: 10.2.10.30, server: localhost, request: "GET /RouteTrfAuth//logon?cpcode=AN_Amap_IOS_FC&batch=0&deviceid=654321 HTTP/1.1", host: "10.2.10.30:9001"
Hello!
On Wed, Nov 6, 2013 at 7:23 PM, zhaojianping [email protected]:
2013/11/07 10:59:27 [error] 16315#0: *128120078 lua entry thread aborted: runtime error: [string "content_by_lua"]:6: module 'logon' not found:
no field package.preload['logon'] no file 'lua/RouteTraffic/lib/logon.lua' no file 'lua/RouteTraffic/logon.lua'
Your error message already lists all the places where the Lua VM tried to load your logon.lua module file.
Check if your logon.lua file is indeed in any of these paths and your file has the right permission for the user account running your nginx worker processes. Alternatively, you can configure the lua_package_path directive in your nginx.conf instead:
https://github.com/chaoslawful/lua-nginx-module#lua_package_path
Also, don't post Chinese here. If you insist, please join the openresty (Chinese) mailing list below and post there instead:
https://groups.google.com/group/openresty
Thank you for you cooperation!
Regards, -agentzh
Consider it resolved.