/usr/share/perl5/Plack/Loader/Delayed.pm is in libplack-perl 1.0042-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | package Plack::Loader::Delayed;
use strict;
use parent qw(Plack::Loader);
sub preload_app {
my($self, $builder) = @_;
$self->{builder} = $builder;
}
sub run {
my($self, $server) = @_;
my $compiled;
my $app = sub {
$compiled ||= $self->{builder}->();
$compiled->(@_);
};
$server->{psgi_app_builder} = $self->{builder};
$server->run($app);
}
1;
__END__
=head1 NAME
Plack::Loader::Delayed - Delay the loading of .psgi until the first run
=head1 SYNOPSIS
plackup -s Starlet -L Delayed myapp.psgi
=head1 DESCRIPTION
This loader delays the compilation of specified PSGI application until
the first request time. This prevents bad things from happening with
preforking web servers like L<Starlet>, when your application
manipulates resources such as sockets or database connections in the
master startup process and then shared by children.
You can combine this loader with C<-M> command line option, like:
plackup -s Starlet -MCatalyst -L Delayed myapp.psgi
loads the module Catalyst in the master process for the better process
management with copy-on-write, however the application C<myapp.psgi>
is loaded per children.
L<Starman> since version 0.2000 loads this loader by default unless
you specify the command line option C<--preload-app> for the
L<starman> executable.
=head1 DEVELOPERS
Web server developers can make use of C<psgi_app_builder> attribute
callback set in Plack::Handler, to load the application earlier than
the first request time.
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
L<plackup>
=cut
|