[Catalyst] Catalyst and PAR

Jonathan Rockway jon at jrock.us
Mon Dec 4 21:17:21 GMT 2006


One of the authors of PAR, Steffen Müller, was kind enough to provide
some feedback in regards to the Advent Calendar article about PAR +
FastCGI.  I'll merge his suggestions into the documentation when I have
a chance, but for now, please take a look at what he has to say.  He
documents a few potentially sticky issues (namely, /tmp being cleared).

Here's his e-mail to me:

-------- Original Message --------
Subject: Catalyst and PAR
Date: Mon, 04 Dec 2006 10:28:03 +0100
From: Steffen Müller <mail at steffen-mueller.net>
To: jrockway at cpan.org

Hi,

thanks for your "Catalyst with FastCGI and PAR" article in the Catalyst
Advent Calendar.

There are a couple of minor things I would like to point out. Some of
them, you probably already know. Perhaps not.

- PAR puts the application files into a temporary directory when the
application is launched. This can be a problem if you don't want them to
reside in /tmp or such. For example if /tmp is cleared regularly. You
can circumvent that by setting the PAR_GLOBAL_TEMP variable in the
script that runs the PAR-packaged app to something like
/var/www-apps/myapp/temp.
- PAR uses a hash of the executable to determine the exact subdirectory
of the temp dir to use for the specific application. There is a bug in
PAR (which I have unsuccessfully tried to fix): If you use "parl ...
myapp.par myapp.pl" to run from myapp.par, the hash of the "parl" binary
will be used. So if you run more than one such packaged applications on
the same server with the same temporary directory, they use the same
cache area. Yes, that's bad. See the previous point above for a work-around.
- With release 0.970, the PAR distribution was split up into PAR (for
using .par's as libraries) which is pure-Perl and PAR::Packer which
contains the binary loader (parl) and all the packaging tools since
those components need a C compiler to set up.

That means you might want to refer to "PAR::Packer" about packaging with
PAR in the future.

There is one more work-around for the bug I mentioned. You can use a
single line of code to use the pure-Perl PAR to run a script from a .par:

use PAR { file => 'foo.par', run => 'bar.pl' };
# doesn't return!

This *always* unpacks into a temporary directory. There won't be any
clashes between various running apps. But it doesn't have the benefit of
caching either, so the start-up time gets a little longer. (Though that
shouldn't matter for a Catalyst app.)

Cheers,
Steffen

-- 
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;



More information about the Catalyst mailing list