Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Mojolicious, Morbo, Hypnotoad and Apache httpd deployment [SOLVED]

by brilant_blue (Beadle)
on Jun 01, 2014 at 17:39 UTC ( [id://1088182]=perlquestion: print w/replies, xml ) Need Help??

brilant_blue has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear Monks!

I am trying to run and deploy an app I wrote in Perl and Mojolicious.

When I use Morbo development server, everything is fine, pretty, fast and simple.

But:

When I try to change Apache httpd config file httpd.conf to work with my Mojolicious app according to documentation on the Internet, all pages of the web app are not available -- 404 HTTP error.

Webpages with docs:
http://mojolicio.us/perldoc/Mojolicious/Guides
http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook
http://mojolicio.us/perldoc/Mojo/Server/Morbo
http://mojolicio.us/perldoc/Mojo/Server/Hypnotoad
https://github.com/kraih/mojo/wiki/Apache-deployment
https://github.com/kraih/mojo/wiki/Hypnotoad-prefork-web-server

Relevant part of file httpd.conf (at the end of file):

<VirtualHost *:80> ServerName localhost ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ <Perl> $ENV{PLACK_ENV} = 'production'; $ENV{MOJO_HOME} = '/var/www/MezlApp'; $ENV{MOJO_MODE} = 'deployment'; </Perl> <Location /> SetHandler perl-script PerlResponseHandler Plack::Handler::Apache2 PerlSetVar psgi_app /var/www/MezlApp/script/runapp </Location> </VirtualHost>

This is the last version of text in httpd.conf. After some playing with it I realized I have no idea how to deploy my app to Apache httpd server and I decided to try to play with Hypnotoad but with no positive effect yet.

When I try to run this app with Hypnotoad server:

$ cd ~

my home directory is /home/martin

$ hypnotoad PokusApp/runhtapp.pl

the command fails with this two sentences:

Deep recursion on subroutine "Mojo::Server::Hypnotoad::run" at /home/martin/PokusApp/runhtapp.pl line 7.

Deep recursion on subroutine "Mojo::Server::load_app" at /usr/share/perl5/vendor_perl/Mojo/Server/Hypnotoad.pm line 35.

File /home/martin/PokusApp/runhtapp.pl:

#!/usr/bin/perl use strict; use warnings; use Mojo::Server::Hypnotoad; my $hypnotoad = Mojo::Server::Hypnotoad->new; $hypnotoad->run('/home/martin/PokusApp/script/runapp'); # Line 7!

File /home/martin/PokusApp/script/runapp:

#!/usr/bin/perl use strict; use warnings; use FDI; # FileDirInfo BEGIN { unshift @INC, "$FDI::cfd/../lib"; } require Mojolicious::Commands; Mojolicious::Commands->start_app('PokusApp');

Where is the bug? What I made wrong?

My operatig system is Fedora 20 i386. I use Perl v5.18.2 and Mojolicious distribution from Fedora's repository. Output of:

$ perl -MMojolicious -e "print Mojolicious->VERSION"

is:

4.25

When I run tests:

$ PokusApp/script/runapp test

All tests successful. Result: PASS

Thank you for your help.

Replies are listed 'Best First'.
Re: Mojolicious, Morbo, Hypnotoad and Apache httpd deployment
by moritz (Cardinal) on Jun 01, 2014 at 19:41 UTC
    <Perl> $ENV{PLACK_ENV} = 'production'; $ENV{MOJO_HOME} = '/var/www/MezlApp'; $ENV{MOJO_MODE} = 'deployment'; </Perl>

    This has no effect whatsoever; Apache won't even start a perl process for you. After all you configured a reverse proxy, not a perl launcher.

    Update: you do seem to set up a perl launcher, but for the location as the reverse proxy. Don't do that.

    So, my advice: start your app the way you usually do, but use hypnotoad instead of morbo - no other changes so far.

    Then test the app with your browser, connecting to hypnotoad directly, not to Apache. Only when that works, you start your apache and try to ues the reverse proxy.

    That way you can cleanly separate debugging hypnotoad startup from the reverse proxy.

Re: Mojolicious, Morbo, Hypnotoad and Apache httpd deployment
by Anonymous Monk on Jun 01, 2014 at 19:11 UTC
    You will inevitably find this sort of thing to be a difference between the dev tool and the actual Apache environment with regard to the Perl library search-order. The classes related to the application cannot be found. Debug the situation by close examination of server logs and/or by adding specific debugging statements to the start of your app that will cause it to tell you what it sees when it is running in the Apache (vs. dev) environments.
Re: Mojolicious, Morbo, Hypnotoad and Apache httpd deployment
by Anonymous Monk on Jun 01, 2014 at 18:11 UTC

    ... runhtapp.pl ...

    Um, no. Hypnotoad wants apps not hypnotoads :) Try running  hypnotoad /home/martin/PokusApp/script/runapp

      $ pwd /home/martin $ hypnotoad PokusApp/script/runapp Couldn't load application from file "/home/martin/PokusApp/script/runa +pp": Couldn't find application class "PokusApp". $

        Is that a confusing message ? Where is application class "PokusApp". located?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1088182]
Approved by Laurent_R
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found