PersistentPerl
view release on metacpan or search on metacpan
src/PersistentPerl.src view on Meta::CPAN
Once mod_persistentperl is installed, it has to be configured to be used
for your perl scripts. There are two methods.
Warning! The instructions below may compromise the security
of your web site. The security risks associated with PersistentPerl are
similar to those of regular CGI. If you don't understand the security
implications of the changes below then don't make them.
=over
=item 1. Path Configuration
This is similar to the way F</cgi-bin> works - everything under this
path is handled by PersistentPerl. Add the following lines near the top of
your httpd.conf - this will cause all scripts in your cgi-bin directory
to be handled by PersistentPerl when they are accessed as F</perperl/script-name>.
Alias /perperl/ /home/httpd/cgi-bin/
<Location /perperl>
SetHandler persistentperl-script
Options ExecCGI
allow from all
</Location>
=item 2. File Extension Configuration
This will make PersistentPerl handle all files with a certain extension,
similar to the way .cgi files work. Add the following lines near the top
of your httpd.conf file - this will set up the file extension ".perperl"
to be handled by PersistentPerl.
AddHandler persistentperl-script .perperl
<Location />
Options ExecCGI
</Location>
=back
=head1 FREQUENTLY ASKED QUESTIONS
=over
=item How does the perperl front end connect to the back end process?
Via a Unix socket in F</tmp>. A queue is kept in a shared file in F</tmp>
that holds an entry for each process. In that queue are the pids of the perl
processes waiting for connections. The frontend pulls a process out of
this queue, connects to its socket, sends over the environment and argv,
and then uses this socket for stdin/stdout to the perl process.
=back
=over
=item If another request comes in while PersistentPerl script is running, does the client
have to wait or is another process started? Is there a way to set a limit
on how many processes get started?
If another request comes while all the perl processes are busy, then
another perl process is started. Just like in regular perl there is normally
no limit on how many processes get started. But, the processes are
only started when the load is so high that they're necessary. If the
load goes down, the processes will die off due to inactivity, unless you
disable the timeout.
Starting in version 1.8.3 an option was added to limit the number
of perl backends running. See B<MaxBackends> in L<"Options Available">
above.
=back
=over
=item How much of perl's state is kept when perperl starts another request?
Do globals keep their values? Are destructors run after the request?
Globals keep their values. Nothing is destroyed after the request.
STDIN/STDOUT/STDERR are closed -- other files are not. C<%ENV> and C<@ARGV>
are the only globals changed between requests.
=back
=over
=item How can I make sure perperl restarts when I edit a perl library used
by the CGI?
Do a touch on the main cgi file that is executed.
The mtime on the main file is checked each time the front-end runs.
=back
=over
=item Do I need to be root to install and/or run PersistentPerl?
No, root is not required.
=back
=over
=item How can I determine if my perl app needs to be changed to work with
perperl? Or is there no modification necessary?
You may have to make modifications.
Globals retain their values between runs, which can be good for keeping
persistent database handles for example, or bad if your code assumes they're
undefined.
Also, if you create global variables with "my", you shouldn't try to
reference those variables from within a subroutine - you should pass them
into the subroutine instead. Or better yet just declare global variables
with "use vars" instead of "my" to avoid the problem altogether.
Here's a good explanation of the problem - it's for mod_perl, but the same
thing applies to persistentperl:
( run in 1.456 second using v1.01-cache-2.11-cpan-39bf76dae61 )