How can you invoke interactive Perl debugging with hypnotoad or morbo?

1.7k Views Asked by At

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

There are 3 best solutions below

3
On

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.

0
On

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.

0
On

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;