Plack/mod_perl routing issues

288 views
Skip to first unread message

Andy O

unread,
Apr 16, 2014, 9:09:45 PM4/16/14
to mojol...@googlegroups.com
Hi,

I am currently using Apache for my deployment because of a custom Apache auth module we use.  So my options (as I see them) are CGI and plack/mod_perl.  Everything was humming along just fine until I added a few more extra routes to the dozen or so I had, then seemingly at random I started getting 404s for routes that I KNOW work.  Restarting Apache would allow the app to work until I hit one of the new routes, which all seem valid and would work intermittently.  The app runs completely fine under CGI (and I would suspect it would run fine under say Hypnotoad as well, but have not tested yet...)

I've seen a few messages like these in the Apache error_log:

Apache2::RequestIO::print: (32) Broken pipe at /usr/share/perl5/Plack/Handler/Apache2.pm line 183

Versions:

# mojo version
CORE
  Perl        (v5.18.2, linux)
  Mojolicious (4.63, Top Hat)

OPTIONAL
  EV 4.0+               (4.15)
  IO::Socket::IP 0.16+  (0.25)
  IO::Socket::SSL 1.75+ (1.965)

# apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Apr 3 2014 12:20:28

Config:

PerlOptions +Parent
<Perl>
 $ENV{PLACK_ENV} = 'production';
 $ENV{MOJO_HOME} = '/mojoapp/portal';
 $ENV{MOJO_MODE} = 'deployment';
</Perl>

<Location /app>
  SetHandler perl-script
  PerlResponseHandler Plack::Handler::Apache2
  PerlSetVar psgi_app /mojoapp/portal/script/portal
</Location>

Any ideas?

Thanks!
-Andy O

Helmut Wollmersdorfer

unread,
Apr 29, 2014, 3:50:48 AM4/29/14
to mojol...@googlegroups.com
Maybe you do something in your new routes which does not confirm to the Plack specification.

Please cut down your code and config files to a test case, reproduce the error and post the complete code here (or on a cut and paste area).

Andy O

unread,
May 12, 2014, 9:38:47 AM5/12/14
to mojol...@googlegroups.com
Problem solved!  Adding PerlSwitches -I/path/to/mojoapp/lib outside of the VirtualHost block in the Apache config fixes the issue.

Helmut Wollmersdorfer

unread,
May 13, 2014, 5:24:50 PM5/13/14
to mojol...@googlegroups.com


Am Montag, 12. Mai 2014 15:38:47 UTC+2 schrieb Andy O:
Problem solved!  Adding PerlSwitches -I/path/to/mojoapp/lib outside of the VirtualHost block in the Apache config fixes the issue.

That's not the best solution. If you set the lib in  your app-script /mojoapp/portal/script/portal then you can benefit from the flexibility of PLACK, i.e you can run it from the console, from t/, within build, with other servers etc.

Andy O

unread,
May 14, 2014, 8:25:56 AM5/14/14
to mojol...@googlegroups.com
I agree, but the "out of box" app-script is not working with my app as it should.  

The script by default contains:

use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }

And I tried:

use lib '/mojoapp/portal/lib';

Same behavior as before, lots of 404s.

Юрий Корик

unread,
Jul 23, 2014, 7:51:25 AM7/23/14
to mojol...@googlegroups.com
I am currently using Apache for my deploymentAny ideas?

Thanks!
-Andy O


Mojolicious 5.16

Apache conf:
--------------------------
--------------------------

<VirtualHost tratata.ua:80>

something parameters

   PerlOptions +Parent
   PerlSwitches -I/var/www/mojo/path_to/lib
   PerlOptions -SetupEnv

        <Location />
            PerlOptions -SetupEnv
            SetHandler perl-script
            PerlHandler Plack::Handler::Apache2
            PerlSetVar psgi_app /var/www/mojo/path_to/script/script_name
        </Location>

something parameters

</VirtualHost>

Script:
--------------------------
--------------------------

#!/usr/bin/env perl

use ModPerl::MethodLookup;
    ModPerl::MethodLookup::preload_all_modules( );
use ModPerl::Util ( );
use Mojolicious::Commands;

$ENV{MOJO_HOME} = '/var/www/mojo/path_to';
$ENV{MOJO_TMPDIR} = '/var/www/mojo/path_to/tmp';
$ENV{MOJO_APP} = 'MyAppName';

$ENV{PLACK_ENV} = 'development';
$ENV{MOJO_MODE} = 'development';
$ENV{MOJO_LOG_LEVEL} = 'debug';
#$ENV{PLACK_ENV} = 'production';
#$ENV{MOJO_MODE} = 'production';
#$ENV{MOJO_LOG_LEVEL} = 'error';
$ENV{MOJO_NO_DETECT} = 0;
$ENV{MOJO_NO_IPV6} = 1;
$ENV{MOJO_NO_BONJOUR} = 1;
$ENV{MOJO_NO_TLS} = 1;
$ENV{MOJO_TEMPLATE_CACHE} = 40;
$ENV{MOJO_RELOAD} = 0;
$ENV{MOJO_CHUNK_SIZE} = 262144;
$ENV{MOJO_MAX_MEMORY_SIZE} = 524288;
$ENV{MOJO_DNS_SERVER} = 'DNS_IP';
$ENV{TZ} = 'Europe/Kiev';
$ENV{MOJO_FATAL_DEPRECATIONS} = 1;

Mojolicious::Commands->start_app('MyAppName');

Reply all
Reply to author
Forward
0 new messages