line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Loader; |
2
|
56
|
|
|
56
|
|
214889
|
use strict; |
|
56
|
|
|
|
|
229
|
|
|
56
|
|
|
|
|
1696
|
|
3
|
56
|
|
|
56
|
|
315
|
use Carp (); |
|
56
|
|
|
|
|
159
|
|
|
56
|
|
|
|
|
922
|
|
4
|
56
|
|
|
56
|
|
23389
|
use Plack::Util; |
|
56
|
|
|
|
|
154
|
|
|
56
|
|
|
|
|
1729
|
|
5
|
56
|
|
|
56
|
|
27883
|
use Try::Tiny; |
|
56
|
|
|
|
|
109518
|
|
|
56
|
|
|
|
|
35917
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
39
|
|
|
39
|
0
|
11647
|
my $class = shift; |
9
|
39
|
|
|
|
|
2339
|
bless {}, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
0
|
0
|
|
sub watch { |
13
|
|
|
|
|
|
|
# do nothing. Override in subclass |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub auto { |
17
|
1
|
|
|
1
|
0
|
19
|
my($class, @args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
50
|
|
|
|
3
|
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
|
|
78
|
$class->load($backend, @args); |
24
|
|
|
|
|
|
|
} catch { |
25
|
1
|
50
|
50
|
1
|
|
27
|
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
|
|
|
|
|
6
|
$class->load('Standalone' => @args); |
31
|
1
|
|
|
|
|
16
|
}; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
15
|
return $server; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub load { |
37
|
39
|
|
|
39
|
0
|
3337
|
my($class, $server, @args) = @_; |
38
|
|
|
|
|
|
|
|
39
|
39
|
|
|
|
|
707
|
my($server_class, $error); |
40
|
|
|
|
|
|
|
try { |
41
|
39
|
|
|
39
|
|
12554
|
$server_class = Plack::Util::load_class($server, 'Plack::Handler'); |
42
|
|
|
|
|
|
|
} catch { |
43
|
1
|
|
33
|
1
|
|
29
|
$error ||= $_; |
44
|
39
|
|
|
|
|
3824
|
}; |
45
|
|
|
|
|
|
|
|
46
|
39
|
100
|
|
|
|
1705
|
if ($server_class) { |
47
|
38
|
|
|
|
|
3045
|
$server_class->new(@args); |
48
|
|
|
|
|
|
|
} else { |
49
|
1
|
|
|
|
|
6
|
die $error; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub preload_app { |
54
|
2
|
|
|
2
|
0
|
12
|
my($self, $builder) = @_; |
55
|
2
|
|
|
|
|
6
|
$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, $builder) = @_; |
84
|
0
|
|
|
|
|
|
$server->run($self->{app}); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |