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

3

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?

Manly answered 14/8, 2015 at 15:16 Comment(0)
M
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.

Men answered 14/8, 2015 at 15:46 Comment(3)
hypnotoad is meant for production use, so hopefully you have fixed all your bugs before you need it. :)Jungian
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. #########Wilen
And with carton that gives us: carton exec perl -d $(carton exec which morbo) ./site.pl.Hiss
F
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;
Feudalize answered 15/7, 2016 at 13:56 Comment(0)
W
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.

Wilen answered 23/6, 2016 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.