我在docker container中有一个openresty应用程序:
FROM openresty/openresty:xenial
RUN luarocks install luasocket
# Add additional binaries into PATH for convenience
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/site/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua"
ENV LUA_CPATH="/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so"
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]下面是nginx.conf示例:
server {
listen 80;
server_name localhost;
# disable code cache, do not need reload nginx with all changes
lua_code_cache off;
location / {
rewrite_by_lua_block {
local Core = require "core"
Core.rewrite()
}
}
}核心lua文件源代码(每行都有断点):
_G.debug = require("debug")
local Core = {}
function Core:rewrite()
require("mobdebug").start("host.docker.internal")
local a = 2
ngx.say(a)
end
return Core因此,我尝试使用EmmyLua (IDEA) + mobdebug来远程调试我的开放式应用程序。
启动调试后+进行http调用:
Start mobdebug server at port:8172
Waiting for process connection...
Connected.在那之后什么都不会发生。我可以看到来自openresty的响应,但debug仍然处于活动状态,并显示消息“Connected。”
我做错了什么?
发布于 2019-07-12 02:48:12
和has_breakpoint_file总是记录time.lua...如果我放了几个断点,那么所有断点都会记录在set_breakpoint中,但has_breakpoint函数中没有一个。
我看不出你的设置有什么问题。只要执行通过该特定行并触发调试钩子,您就会看到对has_breakpoint的调用(除非您正在手动“单步执行”代码)。
如果没有发生这种情况,那么您可能需要检查设置断点的代码是否在协程中执行,因为应该显式启用协程调试。详情请参见this documentation section。
如果这仍然不起作用,您可能想要在mobdebug中的debug_hook函数中添加一些print命令,看看它是否在那些带有断点的行上触发,以及之后会发生什么。
发布于 2019-08-21 22:03:14
如何使用暴露的端口运行docker镜像?是否收到"Bind for 0.0.0.0:8172 failed: port is allocated"?
谢谢你,伊琳娜
https://stackoverflow.com/questions/56959611
复制相似问题