感谢 agentzh 的坚持, 越来越多的人在 openresty 的基础上增补功能了!
刚刚看到的: WebSockets with OpenResty — Medium
https://medium.com/p/1778601c9e05
就是将 node 的绝技,移植到了 lua-resty
只是跟着Aapo 的操作,到最后怎也无法建立连接,
在 日志中报:
[C]: in function 'require'
/usr/local/openresty/nginx/conf/lua/demo2websocket.lua:2: in function
</usr/local/openresty/nginx/conf/lua/demo2websocket.lua:1>, client:
127.0.0.1, server: localhost, request: "GET /s HTTP/1.1", host:
"127.0.0.1:9090"
2013/09/18 12:02:09 [error] 21059#0: *2 lua entry thread aborted:
runtime error: [string "content_by_lua"]:2: module
'resty.websocket.server' not found:
no field package.preload['resty.websocket.server']
no file '/Users/zoomq/Works/lua/4local_lua-resty/websocket/resty/websocket/server.lua'
no file '/usr/local/openresty/lualib/resty/websocket/server.lua'
no file '/usr/local/openresty/lualib/resty/websocket/server/init.lua'
no file './resty/websocket/server.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.0.2/resty/websocket/server.lua'
no file '/usr/local/share/lua/5.1/resty/websocket/server.lua'
no file '/usr/local/share/lua/5.1/resty/websocket/server/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/resty/websocket/server.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/resty/websocket/server/init.lua'
no file '/usr/local/openresty/lualib/resty/websocket/server.so'
no file './resty/websocket/server.so'
no file '/usr/local/lib/lua/5.1/resty/websocket/server.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/resty/websocket/server.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/usr/local/openresty/lualib/resty.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
最后发现, 是 lua_package_path "/path/to/lua-resty-websocket/lib/?.lua;;"; 不起作用
干脆的,
将整个 websocket 目录,复制到了
/usr/local/openresty/lualib/resty/
才对上 require "resty.websocket.server" 的形式,
一切就跑起来了!
爽利!
--
人生苦短, Pythonic! 冗余不做,日子甭过!备份不做,十恶不赦!
KM keep growing environment culture which promoting organization be learnning!
俺: http://about.me/zoom.quiet
许: http://creativecommons.org/licenses/by-sa/2.5/cn/
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
发言: 请发邮件到 openresty@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@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