[Catalyst] Catalyst under Plack (PSGI)

Hernan Lopes hernanlopes at gmail.com
Mon Feb 21 12:43:09 GMT 2011


to configure your logs on catalyst and psgi, create your
myapp/script/my_app.psgi correctly and tell it where to log, like this

#!/usr/bin/env perl
use strict;
use warnings;
use lib ( "./lib" );
use MyApp;

use Catalyst::Engine::PSGI;
use FCGI::ProcManager;
use Plack::Builder;
use Plack::Middleware::AccessLog;
use Plack::Middleware::Debug;

my $name =3D `pwd`;
$name =3D~ s/\W//g;
my $log_dir =3D '/catalyst';
die "log_dir $log_dir does not exist\n" unless -d $log_dir;
die "log_dir $log_dir is not writable\n" unless -w $log_dir;

MyApp->setup_engine('PSGI');
my $app =3D sub { MyApp->run(@_) };

builder {
    my $logfh;
    my $access_logfile =3D "$log_dir/access-log-$name";
    my $error_logfile =3D "$log_dir/error-log-$name";
    open $logfh, ">>", $access_logfile or die $!;
    open STDERR, ">>", $error_logfile or die $!;
    $logfh->autoflush(1);

    enable "AccessLog", logger =3D> sub { print $logfh @_ };

    # if we're using perlbal, fix some request params. replace 12.34.56.78
with your public IP
    enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1'
                    || $_[0]->{REMOTE_ADDR} eq '123.123.123.123' }
    "Plack::Middleware::ReverseProxy";

    return $app;
};


On Mon, Feb 21, 2011 at 9:11 AM, Oleg A. Mamontov <oleg at mamontov.net> wrote:

> Hello.
>
> I trying to switch my Catalyst application from mod_perl to Plack.
> But can't understand how to deal with stderr properly?
> Warning from catalyst goes to stderr and Plack doesn't capture it
> into psgi.errors, is it right behavour?
>
>
> Now i use workaround: C::P::Log::Dispatch and C::P::LogWarnings, but
> it seems to me not the right decision.
>
> Perhaps Catalyst::Engine::PSGI may duplicate stderr with psgi.errors?
>
> --
> Cheers,
> Oleg A. Mamontov
>
> mailto:  oleg at mamontov.net
>
> jabber:  lonerr at charla.mamontov.net
> icq uin: 79-521-617
> cell:    +7-903-798-1352
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110221/e34aa=
a70/attachment.htm


More information about the Catalyst mailing list