line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Loader; |
2
|
56
|
|
|
56
|
|
169618
|
use strict; |
|
56
|
|
|
|
|
139
|
|
|
56
|
|
|
|
|
1345
|
|
3
|
56
|
|
|
56
|
|
279
|
use Carp (); |
|
56
|
|
|
|
|
76
|
|
|
56
|
|
|
|
|
763
|
|
4
|
56
|
|
|
56
|
|
17698
|
use Plack::Util; |
|
56
|
|
|
|
|
118
|
|
|
56
|
|
|
|
|
1281
|
|
5
|
56
|
|
|
56
|
|
21674
|
use Try::Tiny; |
|
56
|
|
|
|
|
89877
|
|
|
56
|
|
|
|
|
31795
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
39
|
|
|
39
|
0
|
5891
|
my $class = shift; |
9
|
39
|
|
|
|
|
1227
|
bless {}, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
0
|
0
|
|
sub watch { |
13
|
|
|
|
|
|
|
# do nothing. Override in subclass |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub auto { |
17
|
1
|
|
|
1
|
0
|
8
|
my($class, @args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
50
|
|
|
|
2
|
my $backend = $class->guess |
20
|
|
|
|
|
|
|
or Carp::croak("Couldn't auto-guess server server implementation. Set it with PLACK_SERVER"); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $server = try { |
23
|
1
|
|
|
1
|
|
48
|
$class->load($backend, @args); |
24
|
|
|
|
|
|
|
} catch { |
25
|
1
|
50
|
50
|
1
|
|
20
|
if (($ENV{PLACK_ENV}||'') eq 'development' or !/^Can't locate /) { |
|
|
|
33
|
|
|
|
|
26
|
|
|
|
|
|
|
warn "Autoloading '$backend' backend failed. Falling back to the Standalone. ", |
27
|
|
|
|
|
|
|
"(You might need to install Plack::Handler::$backend from CPAN. Caught error was: $_)\n" |
28
|
0
|
0
|
0
|
|
|
0
|
if $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'development'; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
2
|
$class->load('Standalone' => @args); |
31
|
1
|
|
|
|
|
8
|
}; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
7
|
return $server; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub load { |
37
|
39
|
|
|
39
|
0
|
3260
|
my($class, $server, @args) = @_; |
38
|
|
|
|
|
|
|
|
39
|
39
|
|
|
|
|
928
|
my($server_class, $error); |
40
|
|
|
|
|
|
|
try { |
41
|
39
|
|
|
39
|
|
11385
|
$server_class = Plack::Util::load_class($server, 'Plack::Handler'); |
42
|
|
|
|
|
|
|
} catch { |
43
|
1
|
|
33
|
1
|
|
20
|
$error ||= $_; |
44
|
39
|
|
|
|
|
4375
|
}; |
45
|
|
|
|
|
|
|
|
46
|
39
|
100
|
|
|
|
2293
|
if ($server_class) { |
47
|
38
|
|
|
|
|
2486
|
$server_class->new(@args); |
48
|
|
|
|
|
|
|
} else { |
49
|
1
|
|
|
|
|
6
|
die $error; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub preload_app { |
54
|
2
|
|
|
2
|
0
|
9
|
my($self, $builder) = @_; |
55
|
2
|
|
|
|
|
4
|
$self->{app} = $builder->(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub guess { |
59
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $env = $class->env; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
return $env->{PLACK_SERVER} if $env->{PLACK_SERVER}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
0
|
|
|
|
if ($env->{PHP_FCGI_CHILDREN} || $env->{FCGI_ROLE} || $env->{FCGI_SOCKET_PATH}) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return "FCGI"; |
67
|
|
|
|
|
|
|
} elsif ($env->{GATEWAY_INTERFACE}) { |
68
|
0
|
|
|
|
|
|
return "CGI"; |
69
|
|
|
|
|
|
|
} elsif (exists $INC{"Coro.pm"}) { |
70
|
0
|
|
|
|
|
|
return "Corona"; |
71
|
|
|
|
|
|
|
} elsif (exists $INC{"AnyEvent.pm"}) { |
72
|
0
|
|
|
|
|
|
return "Twiggy"; |
73
|
|
|
|
|
|
|
} elsif (exists $INC{"POE.pm"}) { |
74
|
0
|
|
|
|
|
|
return "POE"; |
75
|
|
|
|
|
|
|
} else { |
76
|
0
|
|
|
|
|
|
return "Standalone"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
|
sub env { \%ENV } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub run { |
83
|
0
|
|
|
0
|
0
|
|
my($self, $server) = @_; |
84
|
0
|
|
|
|
|
|
$server->run($self->{app}); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |