8

I'm new to mojolicious but have been using Perl for some time. I have to jump through some hoops but I can get the interactive Perl debugger (and Komodo) working with remote connections for Apache but I can't find anything about interactive debugging with hypnotoad or morbo.

The command line examples in the basic tutorial on http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Hello-World work fine because you can launch them with perl -d, but I don't see anyway to tell the hypnotoadctl script to put the service in interactive debug mode ala apache.

Is this not possible? Hints? Tips? Pointers?

3 Answers3

8

morbo and hypnotoad are perl programs, so you can launch them with the -d switch.

perl -d $(which morbo) myMojoApp.pl

It's probably easiest to sprinkle a bunch of $DB::single = 1 statements around you app where you want your initial breakpoints to go and run c as the first debugger command. When you run a request that hits a breakpoint, you'll get a debugger prompt in the terminal that launched morbo.

hypnotoad will be trickier to use with the debugger because it quickly closes all the standard filehandles, calls fork several times, and becomes a daemon.

mob
  • 110,546
  • 17
  • 138
  • 265
  • 3
    `hypnotoad` is meant for production use, so hopefully you have fixed all your bugs before you need it. :) – friedo Aug 14 '15 at 16:52
  • `hypnotoad` exec threads and just exits so debugger interface lost; with `morbo` there error: `######### Forked, but do not know how to create a new TTY. #########` – Eugen Konkov Jun 23 '16 at 11:37
  • And with `carton` that gives us: `carton exec perl -d $(carton exec which morbo) ./site.pl`. – x-yuri Mar 18 '18 at 10:31
2

As JHThorsen points out, standard Mojolicious tests are actually ordinary Perl scripts, so you can debug your tests with:

perl -d t/mytest.t

The -Ilib adds the lib/ directory to the @INC include list so your modules will be loaded.

One catch is that many modules are not loaded until execution time, so if the debugger hassles you about symbols that aren't loaded yet, you'll probably want to set breakpoints after forcing a debug prompt with a carefully inserted

$DB::single = 1;
1

Thanks to 'pink_mist'. You can do:

perl -d myMojoApp.pl daemon -l http://*:29849

But application config is not applyied. I do not know why.

Eugen Konkov
  • 15,716
  • 7
  • 69
  • 107