2

I am using mobDebug. If run a lua script from command line everything works. But when I run them from openresty the Idea doesn't stop. It only writes "Connected/ Disconnected" Configs:

  location / {
    access_by_lua_block {
      local client =  require("client")
  }

client.lua:

    local mobdebug = require("mobdebug");
    mobdebug.start()
    local lfs = require("lfs")
    print("Folder: "..lfs.currentdir())

modebug debug_hook is not invoked for needed lines, set_breakpoints don't invoked.

Idea Debug Logs, but nothing occures:

Idea Debug Logs: Connected/Disconnected

Idea catch debug from terminal client.lua; But it miss it from running nginx.

Irina
  • 939
  • 1
  • 8
  • 26

2 Answers2

2

THIS IS NOT AN ANSWER. It's just that I am experiencing basically the same problem, and comment space is too small to fit all the relevant observations I would like to share:

  1. I was actually able to stop immediately after mobdebug.start() in code running in nginx, and to step-debug - but only in code called directly from init_by_lua_block. This code of course executes once during the server startup or config reload.
  2. I was never able to stop in worker code (e.g. rewrite_by_lua_*). mobdebug.coro() didn't help, and mobdebug.on() threw about "attempt to yield across C-call boundary"
  3. I was only ever able to stop one time, on next statement after mobdebug.start(); once I hit |> (Resume program), it won't stop on any further breakpoints.
Szczepan Hołyszewski
  • 2,707
  • 2
  • 25
  • 39
  • 1
    i have the same problem, it cant stop on any breakpoint, just disconnect, when i remove mobdebug.done(), it can stop on the mobdebug.satrt(), but cant stop on any other breakpoint, any idea? – aiziyuer Aug 11 '19 at 02:04
0

Using mobdebug.loop() is not a correct way to do this, as it's used for live coding, which is not going to work as expected with this setup. mobdebug.start() should be used instead.

Please see an example of how this debugging can be setup with ZeroBrane Studio here: http://notebook.kulchenko.com/zerobrane/debugging-openresty-nginx-lua-scripts-with-zerobrane-studio. All the details to how paths to mobdebug and required modules are configured should still be applicable to your environment.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • Thank you! I've tried start, but it doesn't worked( – Irina Aug 20 '19 at 14:37
  • Doesn't work in what way? It shouldn't be doing more "connected/disconnected" looping, so the debugging should start for sure. – Paul Kulchenko Aug 20 '19 at 17:13
  • It writes: "Can't start debugging for '/Users/igracheva/IdeaProjects/smart-hub/smart-hub/nginx/lua/test_debug.lua'. Compilation error:" – Irina Sep 02 '19 at 07:58